public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Jose E.Marchesi <jemarch@sourceware.org> To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org Subject: [binutils-gdb] libctf: fix refcount leak in ctf_import Date: Thu, 03 Oct 2019 16:34:00 -0000 [thread overview] Message-ID: <20191003163404.119098.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ad613f1d0693e02bdc86047c479315d5f969e2f7 commit ad613f1d0693e02bdc86047c479315d5f969e2f7 Author: Nick Alcock <nick.alcock@oracle.com> Date: Tue Sep 17 06:59:31 2019 +0100 libctf: fix refcount leak in ctf_import Calling ctf_import (fp, NULL) to cancel out a pre-existing import leaked the refcnt increment on the parent, so it could never be freed. New in v4. libctf/ * ctf-open.c (ctf_import): Do not leak a ctf_file_t ref on every ctf_import after the first for a given file. Diff: --- libctf/ChangeLog | 5 +++++ libctf/ctf-open.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/libctf/ChangeLog b/libctf/ChangeLog index b7f12d8..982c335 100644 --- a/libctf/ChangeLog +++ b/libctf/ChangeLog @@ -1,5 +1,10 @@ 2019-09-23 Nick Alcock <nick.alcock@oracle.com> + * ctf-open.c (ctf_import): Do not leak a ctf_file_t ref on every + ctf_import after the first for a given file. + +2019-09-23 Nick Alcock <nick.alcock@oracle.com> + * ctf-impl.h (ctf_str_append_noerr): Declare. * ctf-util.c (ctf_str_append_noerr): Define in terms of ctf_str_append. diff --git a/libctf/ctf-open.c b/libctf/ctf-open.c index 4a95b7f..aedf390 100644 --- a/libctf/ctf-open.c +++ b/libctf/ctf-open.c @@ -1778,6 +1778,7 @@ ctf_import (ctf_file_t *fp, ctf_file_t *pfp) if (fp->ctf_parent != NULL) { + fp->ctf_parent->ctf_refcnt--; ctf_file_close (fp->ctf_parent); fp->ctf_parent = NULL; } @@ -1793,6 +1794,7 @@ ctf_import (ctf_file_t *fp, ctf_file_t *pfp) fp->ctf_flags |= LCTF_CHILD; pfp->ctf_refcnt++; } + fp->ctf_parent = pfp; return 0; }
reply other threads:[~2019-10-03 16:34 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20191003163404.119098.qmail@sourceware.org \ --to=jemarch@sourceware.org \ --cc=bfd-cvs@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).