From: Nick Alcock <nix@sourceware.org>
To: binutils-cvs@sourceware.org
Subject: [binutils-gdb] libctf: don't leak the symbol name in the name->type cache
Date: Fri, 19 Apr 2024 15:51:03 +0000 (GMT) [thread overview]
Message-ID: <20240419155103.CE6833849AD9@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ca019227843f62f5ac0a1c432680e3ca05c4377b
commit ca019227843f62f5ac0a1c432680e3ca05c4377b
Author: Nick Alcock <nick.alcock@oracle.com>
Date: Wed Dec 13 12:24:57 2023 +0000
libctf: don't leak the symbol name in the name->type cache
This cache replaced a cache of symbol index->ctf_id_t. That cache was
just an array, so it could get away with just being free()d, but the
ctfi_symnamedicts cache that replaced it is a full dynhash with a
dynamically-allocated string as the key. As such, it needs freeing with
ctf_dynhash_destroy(), not just free(), or we leak parts of the
underlying hashtab, and all the keys.
libctf/ChangeLog:
* ctf-archive.c (ctf_arc_flush_caches): Fix leak.
Diff:
---
libctf/ctf-archive.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libctf/ctf-archive.c b/libctf/ctf-archive.c
index a0ea838ddc4..a88c6135e1a 100644
--- a/libctf/ctf-archive.c
+++ b/libctf/ctf-archive.c
@@ -699,7 +699,7 @@ void
ctf_arc_flush_caches (ctf_archive_t *wrapper)
{
free (wrapper->ctfi_symdicts);
- free (wrapper->ctfi_symnamedicts);
+ ctf_dynhash_destroy (wrapper->ctfi_symnamedicts);
ctf_dynhash_destroy (wrapper->ctfi_dicts);
wrapper->ctfi_symdicts = NULL;
wrapper->ctfi_symnamedicts = NULL;
reply other threads:[~2024-04-19 15:51 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=20240419155103.CE6833849AD9@sourceware.org \
--to=nix@sourceware.org \
--cc=binutils-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: link
Be 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).