[02/22] libctf: don't leak the symbol name in the name->type cache

Message ID 20240417202018.34966-3-nick.alcock@oracle.com
State New
Series more modifiable CTF dicts (and a few bugfixes) |


Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

Nick Alcock April 17, 2024, 8:19 p.m. UTC
  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.


	* ctf-archive.c (ctf_arc_flush_caches): Fix leak.
 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;