[U-Boot] [PATCH] Prevent malloc with size 0

Marek Vasut marek.vasut at gmail.com
Mon Apr 2 05:36:23 CEST 2012


Dear Mike Frysinger,

> On Sunday 01 April 2012 20:25:44 Graeme Russ wrote:
> > b) The code calling malloc(0) is making a perfectly legitimate assumption
> > 
> >    based on how glibc handles malloc(0)
> 
> not really.  POSIX says malloc(0) is implementation defined (so it may
> return a unique address, or it may return NULL).  no userspace code
> assuming malloc(0) will return non-NULL is correct.

Which is your implementation-defined ;-) But I have to agree with this one. So 
my vote is for returning NULL.

> -mike

Best regards,
Marek Vasut


More information about the U-Boot mailing list