standard error handling for malloc() broken for user root and group wheel

Tim Kientzle tim at kientzle.com
Thu Feb 19 00:13:04 PST 2004


On Wed, 18 Feb 2004, Poul-Henning Kamp wrote:
>
>The situations which can result in the 'a' vs 'A' flag making a
>difference in malloc(3) behavior are all violations of the malloc(3)
>API as defined by ISO C and as such the standard defines the behaviour
>as "undefined".

ANSI/ISO 9899-1990, Section 7.10.3.3 clearly states:

    "The malloc function returns either a null pointer
     or a pointer to the allocated space."

There are no "undefined" possibilities here.  Aborting the program
on a failure to allocate memory is pretty clearly a violation
of the standard, which requires the malloc function to
always return.

Tim Kientzle



More information about the freebsd-current mailing list