Fix ridiculously small memory leak.
authorNick Clifton <nickc@redhat.com>
Fri, 4 Jan 2019 12:11:51 +0000 (12:11 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 4 Jan 2019 12:11:51 +0000 (12:11 +0000)
PR 24001
* objcopy.c (copy_object): Free dhandle after writing out the
debug information.
* objdump.c (dump_bfd): Free dhandle after printing out the debug
information.

binutils/ChangeLog
binutils/objcopy.c
binutils/objdump.c

index 3fc4606d0a69b7017e95e48201c8281df262e06a..c1b2d0b9958ac86475b57eab911ec79d3acdc3dc 100644 (file)
@@ -1,3 +1,11 @@
+2019-01-04  Nick Clifton  <nickc@redhat.com>
+
+       PR 24001
+       * objcopy.c (copy_object): Free dhandle after writing out the
+       debug information.
+       * objdump.c (dump_bfd): Free dhandle after printing out the debug
+       information.
+
 2019-01-01  Alan Modra  <amodra@gmail.com>
 
        Update year range in copyright notice of all files.
index 9bc1230ef938106b60105aa8037a82dcfc42fdeb..0e17b863d5a7d4b95b1dfbc7aa8d6b683b85d592 100644 (file)
@@ -3087,7 +3087,14 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
 
   if (convert_debugging && dhandle != NULL)
     {
-      if (! write_debugging_info (obfd, dhandle, &symcount, &osympp))
+      bfd_boolean res;
+
+      res = write_debugging_info (obfd, dhandle, &symcount, &osympp);
+
+      free (dhandle);
+      dhandle = NULL; /* Paranoia...  */
+
+      if (! res)
        {
          status = 1;
          return FALSE;
index 37a28d5eed2f5c11111a764bca164aede4249b80..220d93a3251842ad23612f07b95c27e3f48f87ea 100644 (file)
@@ -3692,6 +3692,8 @@ dump_bfd (bfd *abfd)
                         bfd_get_filename (abfd));
              exit_status = 1;
            }
+
+         free (dhandle);
        }
       /* PR 6483: If there was no STABS debug info in the file, try
         DWARF instead.  */