diff mbox

[libnftnl] tests: Fix a memory leak

Message ID 77e2db7e796774f9155dcc91531dc8a13bea1a94.1397411811.git.anarey@gmail.com
State Accepted
Headers show

Commit Message

Ana Rey April 13, 2014, 6:08 p.m. UTC
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 <anarey@gmail.com>
---
 tests/nft-parsing-test.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Pablo Neira Ayuso April 14, 2014, 8:49 a.m. UTC | #1
On Sun, Apr 13, 2014 at 08:08:34PM +0200, Ana Rey wrote:
> 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)

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);
 	}