Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Jun 2006 18:09:37 +0200
From:      Matthias Andree <matthias.andree@gmx.de>
To:        freebsd-hackers@freebsd.org
Subject:   Re: Return value of malloc(0)
Message-ID:  <m3bqsceyf2.fsf@merlin.emma.line.org>
In-Reply-To: <20060629054222.GA92895@leiferikson.flosken.lan> (Johannes Weiner's message of "Thu, 29 Jun 2006 07:42:22 %2B0200")
References:  <20060628181045.GA54915@curry.mchp.siemens.de> <20060629054222.GA92895@leiferikson.flosken.lan>

next in thread | previous in thread | raw e-mail | index | archive | help
Johannes Weiner <hnazfoo@googlemail.com> writes:

> Hi,
>
> On Wed, Jun 28, 2006 at 08:10:45PM +0200, Andre Albsmeier wrote:
>> "If you use malloc(0) and are crazy enough to access the 'allocated'
>> memory we give you a SIGSEV to show you how dumb you are :-)".
>
> They should check the return value of malloc() in any case for
> successful allocation.. shouldn't they?

The value returned from malloc(0) must not be dereferenced whatever it
was. It was 0x800, which doesn't count as "failure".

-- 
Matthias Andree



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