fix heap overflow in mac os x.