]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
tests: Fix a memory leak
authorAna Rey <anarey@gmail.com>
Sun, 13 Apr 2014 18:08:34 +0000 (20:08 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 14 Apr 2014 08:49:09 +0000 (10:49 +0200)
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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/nft-parsing-test.c

index 952ffbf11a541642b8a2095d55c0bd2bb8f02114..2a15109b5876e3714cde7f88f7f28776838dcd00 100644 (file)
@@ -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);
        }