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