libctf: actually close bfds we have opened

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.
This commit is contained in:
Nick Alcock 2019-07-29 17:02:48 +01:00
parent edc8bbe90b
commit f046147d59
3 changed files with 8 additions and 1 deletions

View 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);
}