|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH RESEND] libxl: Avoid realloc(, 0) when libxl__xs_directory returns empty list
Ian Campbell writes ("Re: [PATCH RESEND] libxl: Avoid realloc(,0) when
libxl__xs_directory returns empty list"):
> On Tue, 2013-11-12 at 17:23 +0000, Ian Jackson wrote:
> > Ping.
>
> I could have sworn this went in...
Yes. I have found a bunch of these lying around in branches in my
main tree.
> > In three places in libxl this may result in a zero size argument being
> > passed to malloc() or realloc(), which is not adviseable.
>
> I thought it was strictly speaking fine, but I can see why it would be
> best to avoid.
Calling malloc(0) merely produces a fiddly-to-deal-with corner case,
where it may succeed by returning 0.
realloc(something,0) is actually wrong. If it returns 0 you don't
know whether that means "I tried to allocate you a new 0-length block,
but failed, so your original block is still there" or "I have
successfully freed your old block; have this null pointer as an
answer".
> > Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
> > Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
>
> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
And put on the backport list.
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |