summaryrefslogtreecommitdiffstats
path: root/src/rule.c
diff options
context:
space:
mode:
authorAlvaro Neira <alvaroneay@gmail.com>2015-02-11 22:12:21 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2015-02-13 16:52:27 +0100
commit46a475c4649d101726580800b54b81e204083705 (patch)
tree9ee535f8e574a24bdb6ef82783d6feaf85ed827d /src/rule.c
parent5cd8c0d9c58ad7ec64e585722208b1fdf181a593 (diff)
rule: don't release the tree parameter from nft_jansson_parse_rule()
We release the tree that we receive from the parameter in nft_jansson_parse_rule. With this patch, we're going to release the tree where we create it. Therefore, we will have a code more traceable and readable. Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/rule.c')
-rw-r--r--src/rule.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/rule.c b/src/rule.c
index 7f4d049..028dc2e 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -597,10 +597,8 @@ int nft_jansson_parse_rule(struct nft_rule *r, json_t *tree,
nft_rule_add_expr(r, e);
}
- nft_jansson_free_root(tree);
return 0;
err:
- nft_jansson_free_root(tree);
return -1;
}
#endif
@@ -613,12 +611,16 @@ static int nft_rule_json_parse(struct nft_rule *r, const void *json,
#ifdef JSON_PARSING
json_t *tree;
json_error_t error;
+ int ret;
tree = nft_jansson_create_root(json, &error, err, input);
if (tree == NULL)
return -1;
- return nft_jansson_parse_rule(r, tree, err, set_list);
+ ret = nft_jansson_parse_rule(r, tree, err, set_list);
+
+ nft_jansson_free_root(tree);
+ return ret;
#else
errno = EOPNOTSUPP;
return -1;