libctf: actually close bfds we have opened
authorNick Alcock <nick.alcock@oracle.com>
Mon, 29 Jul 2019 16:02:48 +0000 (17:02 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Thu, 3 Oct 2019 16:04:55 +0000 (17:04 +0100)
When we do a ctf_fdopen, we open things via bfd_fdopenr and set up a
hook to close the bfd again... but then we never actually call that hook
from anywhere, so we eventually leak every bfd we open.

Fix this by calling the hook (if set) in ctf_arc_close.

New in v3.

libctf/
* ctf-archive.c (ctf_arc_close): Call ctfi_bfd_close if set.
* ctf-open-bfd.c (ctf_bfdclose): Fix comment.

libctf/ChangeLog
libctf/ctf-archive.c
libctf/ctf-open-bfd.c

index 852ad6267c3636e28148cd63a286517335ddd4ed..ff9e6e52d2e6bbf4c84b0bd4a9e854003e687792 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-30  Nick Alcock  <nick.alcock@oracle.com>
+
+       * ctf-archive.c (ctf_arc_close): Call ctfi_bfd_close if set.
+       * ctf-open-bfd.c (ctf_bfdclose): Fix comment.
+
 2019-07-30  Nick Alcock  <nick.alcock@oracle.com>
 
        * ctf-open-bfd.c (ctf_fdopen): Call bfd_set_cacheable.
index 8de11d6d583e8a892623b8d125d31b30d563429a..979641cc1e728b76ee0956fa7fd5f9514389905f 100644 (file)
@@ -436,6 +436,8 @@ ctf_arc_close (ctf_archive_t *arc)
   free ((void *) arc->ctfi_symsect.cts_data);
   /* Do not free the ctfi_strsect: it is bound to the bfd.  */
   free (arc->ctfi_data);
+  if (arc->ctfi_bfd_close)
+    arc->ctfi_bfd_close (arc);
   free (arc);
 }
 
index 1083c8760856d262e7f73a61e2203aa28e9486ea..d17b72d2f0d4a3b688fc2ecf5eb8942c2e22083f 100644 (file)
@@ -66,7 +66,7 @@ ctf_new_archive_internal (int is_archive, struct ctf_archive *arc,
   return arci;
 }
 
-/* Free the BFD bits of a CTF file on ctf_file_close().  */
+/* Free the BFD bits of a CTF file on ctf_arc_close().  */
 
 static void
 ctf_bfdclose (struct ctf_archive_internal *arci)
This page took 0.027046 seconds and 4 git commands to generate.