summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhil Sutter <psutter@redhat.com>2016-08-12 01:33:33 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2016-08-12 01:45:40 +0200
commitd29f0825c33af8c53a939b7f0e8d5beb2ed48c83 (patch)
tree448cff3f4d9ab27adb8fe56f1f22158b05b8ce21 /src
parent8f003ead750d947cb1ba1c3bc2db44c318a001d2 (diff)
set: prevent memleak in nftnl_jansson_parse_set_info()
During list populating, in error case the function returns without freeing the newly allocated 'elem' object, thereby losing any references to it. Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/set.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/set.c b/src/set.c
index 5f72458..7a41e8c 100644
--- a/src/set.c
+++ b/src/set.c
@@ -610,12 +610,12 @@ static int nftnl_jansson_parse_set_info(struct nftnl_set *s, json_t *tree,
return -1;
json_elem = json_array_get(array, i);
- if (json_elem == NULL)
- return -1;
-
- if (nftnl_jansson_set_elem_parse(elem,
- json_elem, err) < 0)
+ if (json_elem == NULL ||
+ nftnl_jansson_set_elem_parse(elem,
+ json_elem, err) < 0) {
+ free(elem);
return -1;
+ }
list_add_tail(&elem->head, &s->element_list);
}