From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101635 invoked by alias); 3 Oct 2019 16:33:02 -0000 Mailing-List: contact gdb-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: , Sender: gdb-cvs-owner@sourceware.org List-Subscribe: Sender: gdb-cvs-owner@sourceware.org Received: (qmail 101584 invoked by uid 10018); 3 Oct 2019 16:33:02 -0000 Date: Thu, 03 Oct 2019 16:33:00 -0000 Message-ID: <20191003163302.101582.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jose E.Marchesi To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org Subject: [binutils-gdb] libctf: actually close bfds we have opened X-Act-Checkin: binutils-gdb X-Git-Author: Nick Alcock X-Git-Refname: refs/heads/master X-Git-Oldrev: edc8bbe90b82f1fa4f3f261b5c97503867e9aba4 X-Git-Newrev: f046147d59aab0c8b6f00cd182f34b42ac8915e8 X-SW-Source: 2019-10/txt/msg00053.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f046147d59aab0c8b6f00cd182f34b42ac8915e8 commit f046147d59aab0c8b6f00cd182f34b42ac8915e8 Author: Nick Alcock Date: Mon Jul 29 17:02:48 2019 +0100 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. Diff: --- libctf/ChangeLog | 5 +++++ libctf/ctf-archive.c | 2 ++ libctf/ctf-open-bfd.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libctf/ChangeLog b/libctf/ChangeLog index 852ad62..ff9e6e5 100644 --- a/libctf/ChangeLog +++ b/libctf/ChangeLog @@ -1,5 +1,10 @@ 2019-07-30 Nick Alcock + * 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 + * ctf-open-bfd.c (ctf_fdopen): Call bfd_set_cacheable. 2019-07-13 Nick Alcock diff --git a/libctf/ctf-archive.c b/libctf/ctf-archive.c index 8de11d6..979641c 100644 --- a/libctf/ctf-archive.c +++ b/libctf/ctf-archive.c @@ -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); } diff --git a/libctf/ctf-open-bfd.c b/libctf/ctf-open-bfd.c index 1083c87..d17b72d 100644 --- a/libctf/ctf-open-bfd.c +++ b/libctf/ctf-open-bfd.c @@ -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)