From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (wildebeest.demon.nl [212.238.236.112]) by sourceware.org (Postfix) with ESMTPS id 2DF4A383E81A for ; Sun, 10 May 2020 20:01:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2DF4A383E81A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mark@klomp.org Received: from librem (deer0x15.wildebeest.org [172.31.17.151]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 0D8C3300B2FD; Sun, 10 May 2020 22:01:28 +0200 (CEST) Received: by librem (Postfix, from userid 1000) id D3858C031D; Sun, 10 May 2020 22:01:02 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: David Malcolm , Mark Wielaard Subject: [PATCH 7/7] libcpu: Free unused new bitfield on error in i386_parse.y new_bitfield. Date: Sun, 10 May 2020 21:53:40 +0200 Message-Id: <20200510195339.37191-8-mark@klomp.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200510195339.37191-1-mark@klomp.org> References: <20200510195339.37191-1-mark@klomp.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, 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: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 May 2020 20:01:36 -0000 GCC10 -fanalyzer detected we didn't free the newly created bitfield on error. Make sure to free it before returning. Signed-off-by: Mark Wielaard --- libcpu/ChangeLog | 4 ++++ libcpu/i386_parse.y | 1 + 2 files changed, 5 insertions(+) diff --git a/libcpu/ChangeLog b/libcpu/ChangeLog index a8b2b951..a342b7f6 100644 --- a/libcpu/ChangeLog +++ b/libcpu/ChangeLog @@ -1,3 +1,7 @@ +2020-05-09 Mark Wielaard + + * i386_parse.y (new_bitfield): Call free newp on error. + 2020-04-16 Mark Wielaard * i386_disasm.c (i386_disasm): Replace assert with goto invalid_op diff --git a/libcpu/i386_parse.y b/libcpu/i386_parse.y index 910d5458..90c7bd93 100644 --- a/libcpu/i386_parse.y +++ b/libcpu/i386_parse.y @@ -579,6 +579,7 @@ new_bitfield (char *name, unsigned long int num) error (0, 0, "%d: duplicated definition of bitfield '%s'", i386_lineno, name); free (name); + free (newp); return; } -- 2.20.1