diff options
author | Nick Alcock <nick.alcock@oracle.com> | 2019-09-17 06:59:31 +0100 |
---|---|---|
committer | Nick Alcock <nick.alcock@oracle.com> | 2019-10-03 17:04:56 +0100 |
commit | ad613f1d0693e02bdc86047c479315d5f969e2f7 (patch) | |
tree | 196de458dea5edb503823acc749d1e9b635c3a68 /libctf/ctf-open.c | |
parent | 9323dd869dfe481d46512c7f9b1a30d0b7d2d7c4 (diff) | |
download | gdb-ad613f1d0693e02bdc86047c479315d5f969e2f7.zip gdb-ad613f1d0693e02bdc86047c479315d5f969e2f7.tar.gz gdb-ad613f1d0693e02bdc86047c479315d5f969e2f7.tar.bz2 |
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.
Diffstat (limited to 'libctf/ctf-open.c')
-rw-r--r-- | libctf/ctf-open.c | 2 |
1 files changed, 2 insertions, 0 deletions
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; } |