From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id E6E003857C5F for ; Wed, 24 Mar 2021 17:06:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E6E003857C5F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 13C7AAC1D; Wed, 24 Mar 2021 17:06:45 +0000 (UTC) Date: Wed, 24 Mar 2021 18:06:43 +0100 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com, mark@klomp.org Subject: [committed] Fix memory leak in build_abbrevs Message-ID: <20210324170642.GA2685@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: dwz@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Dwz mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Mar 2021 17:06:47 -0000 Hi, 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. Committed to trunk. Thanks, - Tom Fix memory leak in build_abbrevs 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;