]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Import patch from mainline to fix memory leak.
authorNick Clifton <nickc@redhat.com>
Tue, 5 Sep 2017 13:53:37 +0000 (14:53 +0100)
committerNick Clifton <nickc@redhat.com>
Tue, 5 Sep 2017 13:53:37 +0000 (14:53 +0100)
PR binutils/22032
* opncls.c (bfd_close_all_done): Don't call bfd_cache_close
before _close_and_cleanup.  Call iovec->bclose after.
(bfd_close): Remove code common to, and call, bfd_close_all_done.

bfd/ChangeLog
bfd/opncls.c

index db9d0a98482966dbbbd0916181f4df3682997f6f..fc93decfae52648be15981494862c93c724d7d3c 100644 (file)
@@ -1,3 +1,12 @@
+2017-09-05  Nick Clifton  <nickc@redhat.com>
+
+       Import from mainline:
+
+       PR binutils/22032
+       * opncls.c (bfd_close_all_done): Don't call bfd_cache_close
+       before _close_and_cleanup.  Call iovec->bclose after.
+       (bfd_close): Remove code common to, and call, bfd_close_all_done.
+
 2017-09-04  Nick Clifton  <nickc@redhat.com>
 
        Import from mainline:
index 913341c9ffc371fb2f22cd3ea37b359d33ce110e..fa5498685446d97f070c238c09882019f4ec5943 100644 (file)
@@ -726,25 +726,13 @@ RETURNS
 bfd_boolean
 bfd_close (bfd *abfd)
 {
-  bfd_boolean ret;
-
   if (bfd_write_p (abfd))
     {
       if (! BFD_SEND_FMT (abfd, _bfd_write_contents, (abfd)))
        return FALSE;
     }
 
-  if (! BFD_SEND (abfd, _close_and_cleanup, (abfd)))
-    return FALSE;
-
-  ret = abfd->iovec->bclose (abfd) == 0;
-
-  if (ret)
-    _maybe_make_executable (abfd);
-
-  _bfd_delete_bfd (abfd);
-
-  return ret;
+  return bfd_close_all_done (abfd);
 }
 
 /*
@@ -774,7 +762,10 @@ bfd_close_all_done (bfd *abfd)
 {
   bfd_boolean ret;
 
-  ret = bfd_cache_close (abfd);
+  if (! BFD_SEND (abfd, _close_and_cleanup, (abfd)))
+    return FALSE;
+
+  ret = abfd->iovec->bclose (abfd) == 0;
 
   if (ret)
     _maybe_make_executable (abfd);