Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Jun 2006 18:53:34 +0200 (CEST)
From:      Harti Brandt <hartmut.brandt@dlr.de>
To:        Johannes Weiner <hnazfoo@googlemail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Return value of malloc(0)
Message-ID:  <20060629185249.C55888@beagle.kn.op.dlr.de>
In-Reply-To: <20060629162319.GA94921@leiferikson.flosken.lan>
References:  <20060628181045.GA54915@curry.mchp.siemens.de> <20060629054222.GA92895@leiferikson.flosken.lan> <m3bqsceyf2.fsf@merlin.emma.line.org> <20060629162319.GA94921@leiferikson.flosken.lan>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 29 Jun 2006, Johannes Weiner wrote:

JW>On Thu, Jun 29, 2006 at 06:09:37PM +0200, Matthias Andree wrote:
JW>
JW>> The value returned from malloc(0) must not be dereferenced whatever it
JW>> was. It was 0x800, which doesn't count as "failure".
JW>
JW>But this would be appropriate for catching the error:
JW>
JW>if ((foo = malloc(0)) == foo)
JW>	/* make noise */
JW>
JW>wouldn't it?

Wouldn't it rather invoke undefined behaviour?

harti



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060629185249.C55888>