[RFA] ar.c (delete_members): Plug memory leak.
H.J. Lu
hjl.tools@gmail.com
Sun May 1 16:13:00 GMT 2011
On Sun, May 1, 2011 at 9:04 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Mar 8, 2011 at 12:37 PM, Michael Snyder <msnyder@vmware.com> wrote:
>> OK?
>>
>>
>> 2011-03-08 Michael Snyder <msnyder@vmware.com>
>>
>> * ar.c (delete_members): Plug memory leak.
>>
>> Index: ar.c
>> ===================================================================
>> RCS file: /cvs/src/src/binutils/ar.c,v
>> retrieving revision 1.72
>> diff -u -p -r1.72 ar.c
>> --- ar.c 8 Dec 2010 05:05:30 -0000 1.72
>> +++ ar.c 8 Mar 2011 20:35:36 -0000
>> @@ -1117,6 +1121,7 @@ delete_members (bfd *arch, char **files_
>> bfd_boolean found;
>> bfd_boolean something_changed = FALSE;
>> int match_count;
>> + char *tmp = NULL;
>>
>> for (; *files_to_delete != NULL; ++files_to_delete)
>> {
>> @@ -1138,8 +1143,9 @@ delete_members (bfd *arch, char **files_
>> current_ptr_ptr = &(arch->archive_next);
>> while (*current_ptr_ptr)
>> {
>> - if (FILENAME_CMP (normalize (*files_to_delete, arch),
>> - (*current_ptr_ptr)->filename) == 0)
>> + free (tmp);
>> + tmp = normalize (*files_to_delete, arch);
>> + if (FILENAME_CMP (tmp, (*current_ptr_ptr)->filename) == 0)
>> {
>> ++match_count;
>> if (counted_name_mode
>> @@ -1176,6 +1182,7 @@ delete_members (bfd *arch, char **files_
>> write_archive (arch);
>> else
>> output_filename = NULL;
>> + free (tmp);
>> }
>>
>>
>
> The patch is wrong since normalize may not always malloc and
> return a memory. It should be reverted.
>
http://sourceware.org/ml/binutils/2011-03/msg00151.html
http://sourceware.org/ml/binutils/2011-03/msg00154.html
http://sourceware.org/ml/binutils/2011-03/msg00157.html
may have the same issue.
--
H.J.
More information about the Binutils
mailing list