diff options
author | Ana Rey <anarey@gmail.com> | 2014-04-15 12:13:47 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2014-04-16 20:08:12 +0200 |
commit | c3012b12769b40f7d7eb59925f5396e058ffe321 (patch) | |
tree | 429227fd9adc133a7423ac261460540a7a6ad933 /src | |
parent | 16f6d75702e132939d4672e8e9a484be5017935f (diff) |
set-elem: fix a memory leak
Valgrind reports the following memory leak:
valgrind --leak-check=full ./nft-parsing-test -f jsonfiles/63-set.json
==7131== HEAP SUMMARY:
==7131== in use at exit: 2 bytes in 1 blocks
==7131== total heap usage: 155 allocs, 154 frees, 6,497 bytes allocated
==7131==
==7131== 2 bytes in 1 blocks are definitely lost in loss record 1 of 1
==7131== at 0x4C274A0: malloc (vg_replace_malloc.c:291)
==7131== by 0x590B829: strdup (strdup.c:42)
==7131== by 0x4E4341A: nft_data_reg_json_parse (data_reg.c:55)
==7131== by 0x4E4093A: nft_jansson_data_reg_parse (jansson.c:231)
==7131== by 0x4E40A1B: nft_jansson_et_elem_parse (jansson.c:257)
==7131== by 0x4E3CECA: nft_jansson_parse_set (set.c:398)
==7131== by 0x4E3EC65: nft_ruleset_do_parse (ruleset.c:263)
==7131== by 0x401479: test_json (nft-parsing-test.c:129)
==7131== by 0x4017C2: execute_test_file (nft-parsing-test.c:270)
==7131== by 0x400EBB: main (nft-parsing-test.c:332)
Signed-off-by: Ana Rey <anarey@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/set_elem.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/set_elem.c b/src/set_elem.c index a747ba6..05fd08b 100644 --- a/src/set_elem.c +++ b/src/set_elem.c @@ -42,6 +42,12 @@ EXPORT_SYMBOL(nft_set_elem_alloc); void nft_set_elem_free(struct nft_set_elem *s) { + if (s->flags & (1 << NFT_SET_ELEM_ATTR_CHAIN)) { + if (s->data.chain) { + xfree(s->data.chain); + s->data.chain = NULL; + } + } xfree(s); } EXPORT_SYMBOL(nft_set_elem_free); |