scandir leak patch
Jeff Johnston
jjohnstn@redhat.com
Mon Nov 24 20:44:00 GMT 2008
Joel Sherrill wrote:
>
> Attached is the current newlib scandir.c with
> the "goto cleanup_and_bail" modification from
> the RTEMS one plus an explicit check for 0
> entries from the fstat.
>
> How does this look?
>
> 2008-11-24 Joel Sherrill <joel.sherrill@oarcorp.com>
>
> * libc/posix/scandir.c: Fix memory leaks.
>
Hi Joel,
Thanks. I did some cleanup of your patch. First of all you should
have been using reallocf instead of realloc
since you reset the input pointer. Secondly I wasn't thrilled with the
cleanup_and_bail section occurring after the normal return so I added a
flag to indicate "if successful" and used it so there would only be the
one return statement. Let me know if I missed anything or whether you
have any problems with the modifications.
I have attached a new diff which would be applied to the original
scandir.c.
-- Jeff J.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: scandir.patch
URL: <http://sourceware.org/pipermail/newlib/attachments/20081124/21a2208d/attachment.ksh>
More information about the Newlib
mailing list