From 111c6c9c326113cda15ea9180ff8f4b5377434cf Mon Sep 17 00:00:00 2001
From: Phil Sutter <psutter@redhat.com>
Date: Tue, 16 May 2017 12:28:55 +0200
Subject: [PATCH] set: prevent memleak in nftnl_jansson_parse_set_info()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1353311
Upstream Status: libnftnl commit d29f0825c33af
commit d29f0825c33af8c53a939b7f0e8d5beb2ed48c83
Author: Phil Sutter <psutter@redhat.com>
Date: Fri Aug 12 01:33:33 2016 +0200
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>
---
src/set.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/set.c b/src/set.c
index dbea93b..9560ccc 100644
--- a/src/set.c
+++ b/src/set.c
@@ -566,12 +566,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);
}
--
1.8.3.1