From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2103) id CE6833849AD9; Fri, 19 Apr 2024 15:51:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE6833849AD9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713541863; bh=YIqUp3OaJE0zz1qC/rlmnSndfAPXcdIN27453qdEFck=; h=From:To:Subject:Date:From; b=cjipxiyv7SYkLhNH2CCR4Wt/1suBmBx/PxWbGDYnOLphWK9JNRZCirKrt7nWYiJvv Jx7EVEoy1FcFg7V49DvoIPt2OFXLofjsY9xJbsAihlO2ls0vHF/MSpYceVsUpwxK8s 2pLueKgRKmvxq2ncZXLmix+sVVOk8sa7KIV1FHfo= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Nick Alcock To: binutils-cvs@sourceware.org Subject: [binutils-gdb] libctf: don't leak the symbol name in the name->type cache X-Act-Checkin: binutils-gdb X-Git-Author: Nick Alcock X-Git-Refname: refs/heads/master X-Git-Oldrev: 6364617120e3886b79e0ba89f2c1506766ed4e98 X-Git-Newrev: ca019227843f62f5ac0a1c432680e3ca05c4377b Message-Id: <20240419155103.CE6833849AD9@sourceware.org> Date: Fri, 19 Apr 2024 15:51:03 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dca019227843f= 62f5ac0a1c432680e3ca05c4377b commit ca019227843f62f5ac0a1c432680e3ca05c4377b Author: Nick Alcock Date: Wed Dec 13 12:24:57 2023 +0000 libctf: don't leak the symbol name in the name->type cache =20 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. =20 libctf/ChangeLog: =20 * 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 =3D NULL; wrapper->ctfi_symnamedicts =3D NULL;