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

Wolfgang Denk wd at denx.de
Thu Oct 21 13:32:54 CEST 2010


Dear Joakim Tjernlund,

In message <OF9263CF56.48468959-ONC12577C3.003E4D93-C12577C3.003ECAD7 at transmode.se> you wrote:
>
> > -  if ((long)bytes < 0) return 0;
> > +  if ((long)bytes <= 0) return 0;
> 
> I think you should return some impossible ptr value =! NULL
> Size 0 not really an error. 

It is legal for malloc() to return NULL in case of size==0,
and for the sake of simplicity I recommend we do just that.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If the hours are long enough and the pay  is  short  enough,  someone
will say it's women's work.


More information about the U-Boot mailing list