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

Joakim Tjernlund joakim.tjernlund at transmode.se
Thu Oct 21 13:45:10 CEST 2010


Wolfgang Denk <wd at denx.de> wrote on 2010/10/21 13:32:54:
> 
> 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.

Yes, but not very useful. Glibc does not return NULL


More information about the U-Boot mailing list