Fix BFD leak in solib-darwin.c
authorTom Tromey <tromey@adacore.com>
Thu, 21 Feb 2019 17:40:49 +0000 (10:40 -0700)
committerTom Tromey <tromey@adacore.com>
Mon, 25 Feb 2019 13:55:02 +0000 (06:55 -0700)
commit 192b62ce0b4bb5c61188f570e127a26d2c32f716 ("Use class to manage
BFD reference counts") changed darwin_get_dyld_bfd to use:

+ dyld_bfd.release ();

rather than

-      do_cleanups (cleanup);

However, using release here leaks the BFD.  Instead, simply assigning
"sub" to "dyld_bfd" achieves what was meant.

gdb/ChangeLog
2019-02-25  Tom Tromey  <tromey@adacore.com>

* solib-darwin.c (darwin_get_dyld_bfd): Don't release dyld_bfd.

gdb/ChangeLog
gdb/solib-darwin.c

index 9a5740210b39f177c00613f6061f5ff633a7b739..118f17588a8d38e529f89d08b2f8d38533dc6393 100644 (file)
@@ -1,3 +1,7 @@
+2019-02-25  Tom Tromey  <tromey@adacore.com>
+
+       * solib-darwin.c (darwin_get_dyld_bfd): Don't release dyld_bfd.
+
 2019-02-23  Sergio Durigan Junior  <sergiodj@redhat.com>
 
        * gcore.in: Add '--readnever' option when invoking GDB.
index d3060604badf47b55d00d77536d6df021db148c2..b976b79091a06984eb6c6139f007de028d04b510 100644 (file)
@@ -452,10 +452,7 @@ darwin_get_dyld_bfd ()
       gdb_bfd_ref_ptr sub
        (gdb_bfd_mach_o_fat_extract (dyld_bfd.get (), bfd_object,
                                     gdbarch_bfd_arch_info (target_gdbarch ())));
-      if (sub != NULL)
-       dyld_bfd = sub;
-      else
-       dyld_bfd.release ();
+      dyld_bfd = sub;
     }
   return dyld_bfd;
 }