From patchwork Sun Apr 13 18:08:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ana Rey X-Patchwork-Id: 338772 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 7CA4D140089 for ; Mon, 14 Apr 2014 04:08:54 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755010AbaDMSIx (ORCPT ); Sun, 13 Apr 2014 14:08:53 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:56700 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754785AbaDMSIv (ORCPT ); Sun, 13 Apr 2014 14:08:51 -0400 Received: by mail-wi0-f181.google.com with SMTP id hm4so3087649wib.2 for ; Sun, 13 Apr 2014 11:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IvluscdsgSqFsW9IYHWLhBOSNuiiqyr9jeK2IFpXu4I=; b=amDeKYxBwzckDEks/CNRj/01evpliyYStWkYm9IQ0UHvqXASzAG2w4s2111PSfq+EM 9XxynWes56z/4096IjpXCa/GlmJdLw9ABLNa9AILuFI+T7o8ia1F9o/P1t+IUmG/rEI5 HkD/LsIEKQ/dq2nuE1rBNXl7z0hCigZXEZLz8KVUrbT78K8x8ZE3e965C16qLxZYH4zH niik5j1Q1XjlG7t+FBXYcQvxz0eQk/KKiC1fnHTnpwa6xhZHBD3SwqT3ffwu2t2PAm4h gvZLmL5gTUOmT3aV+qZFEHoVFBhvEk9hZSSLm+LurpruqbGnUb0Yz0YW37RBScQpjHDj tfWA== X-Received: by 10.194.243.3 with SMTP id wu3mr29478181wjc.29.1397412530653; Sun, 13 Apr 2014 11:08:50 -0700 (PDT) Received: from localhost.localdomain (212.Red-217-125-252.dynamicIP.rima-tde.net. [217.125.252.212]) by mx.google.com with ESMTPSA id hu7sm18147784wib.10.2014.04.13.11.08.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 13 Apr 2014 11:08:49 -0700 (PDT) From: Ana Rey To: netfilter-devel@vger.kernel.org Cc: Ana Rey Subject: [libnftnl PATCH] tests: Fix a memory leak Date: Sun, 13 Apr 2014 20:08:34 +0200 Message-Id: <77e2db7e796774f9155dcc91531dc8a13bea1a94.1397411811.git.anarey@gmail.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <3a6157fa2be7124bafa2b681acb65eea9be432d2.1397411873.git.anarey@gmail.com> References: <3a6157fa2be7124bafa2b681acb65eea9be432d2.1397411873.git.anarey@gmail.com> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Free nft_parse_err struct when there is an error in execute_test function. It solves the following memory leak shown by valgrind. ==7845== 24 bytes in 1 blocks are still reachable in loss record 1 of 2 ==7845== at 0x4C29590: calloc (vg_replace_malloc.c:618) ==7845== by 0x401740: execute_test_file (nft-parsing-test.c:249) ==7845== by 0x400EBB: main (nft-parsing-test.c:330) Signed-off-by: Ana Rey --- tests/nft-parsing-test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c index 952ffbf..2a15109 100644 --- a/tests/nft-parsing-test.c +++ b/tests/nft-parsing-test.c @@ -263,6 +263,7 @@ static int execute_test_file(const char *filename) printf("\033[32mOK\e[0m\n"); } } + nft_parse_err_free(err); exit(EXIT_FAILURE); } if (strcmp(&filename[len-5], ".json") == 0) { @@ -273,6 +274,7 @@ static int execute_test_file(const char *filename) printf("\033[32mOK\e[0m\n"); } } + nft_parse_err_free(err); exit(EXIT_FAILURE); }