This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH v4 35/35 NEW] libctf: fix refcount leak in ctf_import
- From: Nick Alcock <nick dot alcock at oracle dot com>
- To: binutils at sourceware dot org
- Cc: Nick Alcock <nick dot alcock at oracle dot com>
- Date: Tue, 24 Sep 2019 14:51:31 +0100
- Subject: [PATCH v4 35/35 NEW] libctf: fix refcount leak in ctf_import
- References: <20190924135131.441906-1-nick.alcock@oracle.com>
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.
---
libctf/ctf-open.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libctf/ctf-open.c b/libctf/ctf-open.c
index 4a95b7f38a5..aedf39086a2 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;
}
--
2.23.0.239.g28aa4420fd