This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[RFA] ar.c (move_members): Plug memory leak.
- From: Michael Snyder <msnyder at vmware dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Tue, 08 Mar 2011 12:20:12 -0800
- Subject: [RFA] ar.c (move_members): Plug memory leak.
OK?
2011-03-08 Michael Snyder <msnyder@vmware.com>
* ar.c (move_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:18:42 -0000
@@ -1186,6 +1186,7 @@ move_members (bfd *arch, char **files_to
{
bfd **after_bfd; /* New entries go after this one */
bfd **current_ptr_ptr; /* cdr pointer into contents */
+ char *tmp = NULL;
for (; *files_to_move; ++files_to_move)
{
@@ -1193,8 +1194,9 @@ move_members (bfd *arch, char **files_to
while (*current_ptr_ptr)
{
bfd *current_ptr = *current_ptr_ptr;
- if (FILENAME_CMP (normalize (*files_to_move, arch),
- current_ptr->filename) == 0)
+ free (tmp);
+ tmp = normalize (*files_to_move, arch);
+ if (FILENAME_CMP (tmp, current_ptr->filename) == 0)
{
/* Move this file to the end of the list - first cut from
where it is. */
@@ -1218,10 +1220,12 @@ move_members (bfd *arch, char **files_to
/* xgettext:c-format */
fatal (_("no entry %s in archive %s!"), *files_to_move, arch->filename);
- next_file:;
+ next_file:
+ ;
}
write_archive (arch);
+ free (tmp);
}
/* Ought to default to replacing in place, but this is existing practice! */