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

index 832e8ac6de18b9257f06d808f533227d84229507..d369ae88d46c7bf71b98a60eca0faf52e9bdf233 100644 (file)
@@ -1,6 +1,7 @@
 2011-03-25  Michael Snyder  <msnyder@vmware.com>
 
        * strings.c (print_strings): Plug memory leak.
+       * ar.c (move_members): Plug memory leak.
 
 2011-03-25  Pierre Muller  <muller@ics.u-strasbg.fr>
 
index 0866a54f2aee048457703a7c998a9cf427104a2d..6320a28ddcb4e3c8a78217ea95ec336a0dcc885c 100644 (file)
@@ -1185,8 +1185,9 @@ delete_members (bfd *arch, char **files_to_delete)
 static void
 move_members (bfd *arch, char **files_to_move)
 {
-  bfd **after_bfd;             /* New entries go after this one */
-  bfd **current_ptr_ptr;       /* cdr pointer into contents */
+  bfd **after_bfd;             /* New entries go after this one.  */
+  bfd **current_ptr_ptr;       /* cdr pointer into contents.  */
+  const char *tmp = NULL;
 
   for (; *files_to_move; ++files_to_move)
     {
@@ -1194,8 +1195,11 @@ move_members (bfd *arch, char **files_to_move)
       while (*current_ptr_ptr)
        {
          bfd *current_ptr = *current_ptr_ptr;
-         if (FILENAME_CMP (normalize (*files_to_move, arch),
-                           current_ptr->filename) == 0)
+
+         if (tmp != NULL)
+           free ((char *) 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.  */
@@ -1219,10 +1223,13 @@ move_members (bfd *arch, char **files_to_move)
       /* xgettext:c-format */
       fatal (_("no entry %s in archive %s!"), *files_to_move, arch->filename);
 
-    next_file:;
+    next_file:
+      ;
     }
 
   write_archive (arch);
+  if (tmp != NULL)
+    free ((char *) tmp);
 }
 
 /* Ought to default to replacing in place, but this is existing practice!  */
This page took 0.027704 seconds and 4 git commands to generate.