From d0e071f159b072ce985bc8397e98ef25fe788047 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Wed, 24 Mar 2021 18:05:20 +0100 Subject: [PATCH] Fix memory leak in build_abbrevs Conflict:NA Reference:https://sourceware.org/git/?p=dwz.git;a=patch;h=d0e071f159b072ce985bc8397e98ef25fe788047 I noticed that build_abbrevs leaks h in case the "return 1" path is taken: ... htab_t h = htab_try_create (50, abbrev_hash, abbrev_eq2, NULL); if (h == NULL) dwz_oom (); if (build_abbrevs_for_die (h, cu, cu->cu_die, NULL, NULL, t, ndies, vec, false)) return 1; ... Fix this by calling htab_delete before returning 1. 2021-03-24 Tom de Vries * dwz.c (build_abbrevs): Clean up in case of return 1. --- dwz.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dwz.c b/dwz.c index b212d6d..436bae1 100644 --- a/dwz.c +++ b/dwz.c @@ -11234,7 +11234,10 @@ build_abbrevs (dw_cu_ref cu, struct abbrev_tag *t, unsigned int *ndies, if (build_abbrevs_for_die (h, cu, cu->cu_die, NULL, NULL, t, ndies, vec, false)) - return 1; + { + htab_delete (h); + return 1; + } cu->cu_new_abbrev = h; return 0; -- 2.33.0