Return value of malloc(0)

Matthias Andree matthias.andree at gmx.de
Thu Jun 29 16:09:46 UTC 2006


Johannes Weiner <hnazfoo at 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


More information about the freebsd-hackers mailing list