What happens when realloc() returns NULL?

Doug Gwyn gwyn at smoke.BRL.MIL
Fri Sep 1 09:04:33 AEST 1989


In article <1103 at virtech.UUCP> cpcahil at virtech.UUCP (Conor P. Cahill) writes:
>System V Rel 2.x:	When this happens the block pointed to by ptr may
>       			be destroyed.

The SVID Issue 2 does not permit that, though, and SVR2.0 in fact does
not overwrite the storage.  However, the block at ptr is marked as
being free, which makes it tricky to recover, since any further use of
malloc() or realloc() might step on the freed data.  Although the C
Standard is not crystal-clear on this point, the intent is that the
block is supposed to still be allocated.

This was (correctly) noted as a "BUG" in some manual pages.



More information about the Comp.lang.c mailing list