bug-fixes for malloc