I would guess memory corruption.
Are you freeing the pointer returned from this function appropriately?