* ar.c (delete_members): Plug memory leak.
authorNick Clifton <nickc@redhat.com>
Fri, 25 Mar 2011 17:17:03 +0000 (17:17 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 25 Mar 2011 17:17:03 +0000 (17:17 +0000)
binutils/ChangeLog
binutils/ar.c

index d369ae88d46c7bf71b98a60eca0faf52e9bdf233..ae56956a5dce2c4535ec7cb7692803722cb92036 100644 (file)
@@ -2,6 +2,7 @@
 
        * strings.c (print_strings): Plug memory leak.
        * ar.c (move_members): Plug memory leak.
+       (delete_members): Plug memory leak.
 
 2011-03-25  Pierre Muller  <muller@ics.u-strasbg.fr>
 
index 6320a28ddcb4e3c8a78217ea95ec336a0dcc885c..263795fb7ee5e866ae2799f7720427ee2ea972b3 100644 (file)
@@ -1118,6 +1118,7 @@ delete_members (bfd *arch, char **files_to_delete)
   bfd_boolean found;
   bfd_boolean something_changed = FALSE;
   int match_count;
+  const char * tmp = NULL;
 
   for (; *files_to_delete != NULL; ++files_to_delete)
     {
@@ -1139,8 +1140,10 @@ delete_members (bfd *arch, char **files_to_delete)
       current_ptr_ptr = &(arch->archive_next);
       while (*current_ptr_ptr)
        {
-         if (FILENAME_CMP (normalize (*files_to_delete, arch),
-                           (*current_ptr_ptr)->filename) == 0)
+         if (tmp != NULL)
+           free ((char *) tmp);
+         tmp = normalize (*files_to_delete, arch);
+         if (FILENAME_CMP (tmp, (*current_ptr_ptr)->filename) == 0)
            {
              ++match_count;
              if (counted_name_mode
@@ -1177,6 +1180,9 @@ delete_members (bfd *arch, char **files_to_delete)
     write_archive (arch);
   else
     output_filename = NULL;
+
+  if (tmp != NULL)
+    free ((char *) tmp);
 }