how does free() know how much to free?

Glen Herrmannsfeldt gah at hood.hood.caltech.edu
Thu Feb 28 12:39:14 AEST 1991


Many free()'s store the length at the address right before the
allocated space.  (Often aligned on a nice boundary.)
If you reference element -1 in your malloc'ed array, you may
destroy the length, and cause lots of strange effects.



More information about the Comp.lang.c mailing list