From patchwork Tue Jan 8 06:24:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Waroquiers X-Patchwork-Id: 30996 Received: (qmail 14913 invoked by alias); 8 Jan 2019 06:25:06 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 14878 invoked by uid 89); 8 Jan 2019 06:25:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=H*Ad:D*be, HContent-Transfer-Encoding:8bit X-HELO: mailsec112.isp.belgacom.be Received: from mailsec112.isp.belgacom.be (HELO mailsec112.isp.belgacom.be) (195.238.20.108) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Jan 2019 06:25:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1546928701; x=1578464701; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=fCC39u6gyi5b2ToRKmztrGkel2cw+bxmvxSPeYLScqw=; b=m+L694A7Y+SflguNQZF4tJt88NHOXeRl/He2uB+7GO+kNxKhZNxx3T0V si53ICCZVz1c+wn3JGcsp8QYpY+JRQ==; Received: from 184.205-67-87.adsl-dyn.isp.belgacom.be (HELO md.home) ([87.67.205.184]) by relay.skynet.be with ESMTP/TLS/DHE-RSA-AES128-GCM-SHA256; 08 Jan 2019 07:24:58 +0100 From: Philippe Waroquiers To: gdb-patches@sourceware.org Cc: Philippe Waroquiers Subject: [RFA] Fix leak in linespec.c Date: Tue, 8 Jan 2019 07:24:52 +0100 Message-Id: <20190108062452.3942-1-philippe.waroquiers@skynet.be> MIME-Version: 1.0 X-IsSubscribed: yes Valgrind reports a leak in many tests, such as: ==9382== 16 bytes in 1 blocks are definitely lost in loss record 236 of 3,282 ==9382== at 0x4C2BE6D: malloc (vg_replace_malloc.c:309) ==9382== by 0x4197AF: xrealloc (common-utils.c:64) ==9382== by 0x51D16A: xresizevec (poison.h:170) ==9382== by 0x51D16A: add_sal_to_sals(linespec_state*, std::vector >*, symtab_and_line*, char const*, int) (linespec.c:1041) ==9382== by 0x51E2BF: create_sals_line_offset (linespec.c:2215) ==9382== by 0x51E2BF: convert_linespec_to_sals(linespec_state*, linespec*) (linespec.c:2358) ==9382== by 0x521B5D: convert_explicit_location_to_sals (linespec.c:2473) Fix leak by xfree-ing self->canonical_names in linespec_state_destructor. The leak probably appeared with the patch 'Remove cleanup from linespec.c', as there was a cleanup to xfree canonical_names before the patch. Tested on Debian/amd64, native and under valgrind. 2019-01-07 Philippe Waroquiers * linespec.c (linespec_state_destructor): Free self->canonical_names. --- gdb/linespec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gdb/linespec.c b/gdb/linespec.c index b1ab462e66..f6ef4c2c40 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -2767,6 +2767,7 @@ static void linespec_state_destructor (struct linespec_state *self) { htab_delete (self->addr_set); + xfree (self->canonical_names); } /* Delete a linespec parser. */