From patchwork Sun Sep 13 22:57:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 517243 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 52ACB1401AD for ; Mon, 14 Sep 2015 09:04:15 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7D0C54B6F3; Mon, 14 Sep 2015 01:04:11 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wWWZ14QZ4bOY; Mon, 14 Sep 2015 01:04:10 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 249CE4B6C3; Mon, 14 Sep 2015 01:04:10 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F2EAB4B69C for ; Mon, 14 Sep 2015 01:03:50 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id v5xhoC_waq43 for ; Mon, 14 Sep 2015 01:03:49 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from 10.mo4.mail-out.ovh.net (10.mo4.mail-out.ovh.net [188.165.33.109]) by theia.denx.de (Postfix) with ESMTPS id 299704B67D for ; Mon, 14 Sep 2015 01:03:43 +0200 (CEST) Received: from mail194.ha.ovh.net (gw6.ovh.net [213.251.189.206]) by mo4.mail-out.ovh.net (Postfix) with SMTP id 2D224FFA81C for ; Mon, 14 Sep 2015 00:57:34 +0200 (CEST) Received: from localhost (HELO queueout) (127.0.0.1) by localhost with SMTP; 14 Sep 2015 00:57:34 +0200 Received: from 109241105088.warszawa.vectranet.pl (HELO localhost.localdomain) (l.majewski%majess.pl@109.241.105.88) by ns0.ovh.net with SMTP; 14 Sep 2015 00:57:31 +0200 From: Lukasz Majewski To: Tom Rini , u-boot@lists.denx.de Date: Mon, 14 Sep 2015 00:57:04 +0200 Message-Id: <1442185024-14645-2-git-send-email-l.majewski@majess.pl> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1442185024-14645-1-git-send-email-l.majewski@majess.pl> References: <1442185024-14645-1-git-send-email-l.majewski@majess.pl> X-Ovh-Tracer-Id: 18400300702622794251 X-Ovh-Remote: 109.241.105.88 (109241105088.warszawa.vectranet.pl) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: -100 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeekgedrvdefucetufdoteggucfrrhhofhhilhgvmecuqfggjfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeekgedrvdefucetufdoteggucfrrhhofhhilhgvmecuqfggjfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm Subject: [U-Boot] [PATCH 2/2] FIX: env: import: hashtable: Free memory allocated before exiting from himport_r() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Without this patch memory is not released on early exit. Signed-off-by: Lukasz Majewski --- lib/hashtable.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/hashtable.c b/lib/hashtable.c index 7df424a..02b4105 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -842,8 +842,10 @@ int himport_r(struct hsearch_data *htab, } } - if(!size) + if (!size) { + free(data); return 1; /* everything OK */ + } if(crlf_is_lf) { /* Remove Carriage Returns in front of Line Feeds */ unsigned ignored_crs = 0; @@ -907,6 +909,7 @@ int himport_r(struct hsearch_data *htab, if (*name == 0) { debug("INSERT: unable to use an empty key\n"); __set_errno(EINVAL); + free(data); return 0; }