]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
libctf: don't leak the symbol name in the name->type cache
authorNick Alcock <nick.alcock@oracle.com>
Wed, 13 Dec 2023 12:24:57 +0000 (12:24 +0000)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 19 Apr 2024 15:14:45 +0000 (16:14 +0100)
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.

libctf/ctf-archive.c

index a0ea838ddc47c52309de27b034002c66dccc529e..a88c6135e1a36db312342ef990277c0f2e730307 100644 (file)
@@ -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;