From: Alvaro Neira Ayuso <alvaroneay@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: [libnftnl PATCH v2] rule: don't release the tree parameter in the function nft_jansson_parse_rule
Date: Wed, 11 Feb 2015 22:12:21 +0100 [thread overview]
Message-ID: <1423689142-6300-1-git-send-email-alvaroneay@gmail.com> (raw)
Already, 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>
---
[changes in v2]
* Reworked the description
src/rule.c | 8 +++++---
1 file 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;
--
1.7.10.4
next reply other threads:[~2015-02-11 21:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-11 21:12 Alvaro Neira Ayuso [this message]
2015-02-11 21:12 ` [libnftnl PATCH v2] ruleset: fix a leak when we use the set lists Alvaro Neira Ayuso
2015-02-13 15:57 ` Pablo Neira Ayuso
2015-02-13 16:04 ` Álvaro Neira Ayuso
2015-02-13 15:56 ` [libnftnl PATCH v2] rule: don't release the tree parameter in the function nft_jansson_parse_rule Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1423689142-6300-1-git-send-email-alvaroneay@gmail.com \
--to=alvaroneay@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).