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

Wolfgang Denk
2010-10-21T11:32:54Z

Dear Joakim Tjernlund,

In message <OF9263CF56.48468959-ONC12577C3.003E4D93-C12577C3.003ECAD7@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.