From: Ana Rey <anarey@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: Ana Rey <anarey@gmail.com>
Subject: [libnftnl PATCH 4/5] src: set: Free memory in the same function that is reserved.
Date: Wed, 11 Jun 2014 17:50:50 +0200 [thread overview]
Message-ID: <1402501851-22208-6-git-send-email-anarey@gmail.com> (raw)
In-Reply-To: <1402501851-22208-1-git-send-email-anarey@gmail.com>
Free memory in the same function that is reserved.
Signed-off-by: Ana Rey <anarey@gmail.com>
---
src/set.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/set.c b/src/set.c
index 152b81c..53e5db1 100644
--- a/src/set.c
+++ b/src/set.c
@@ -377,7 +377,7 @@ int nft_jansson_parse_set(struct nft_set *s, json_t *tree,
if (nft_jansson_node_exist(root, "data_type")) {
if (nft_jansson_parse_val(root, "data_type", NFT_TYPE_U32,
&uval32, err) < 0)
- goto err;
+ return -1;
nft_set_attr_set_u32(s, NFT_SET_ATTR_DATA_TYPE, uval32);
}
@@ -385,7 +385,7 @@ int nft_jansson_parse_set(struct nft_set *s, json_t *tree,
if (nft_jansson_node_exist(root, "data_len")) {
if (nft_jansson_parse_val(root, "data_len", NFT_TYPE_U32,
&uval32, err) < 0)
- goto err;
+ return -1;
nft_set_attr_set_u32(s, NFT_SET_ATTR_DATA_LEN, uval32);
}
@@ -395,27 +395,22 @@ int nft_jansson_parse_set(struct nft_set *s, json_t *tree,
for (i = 0; i < json_array_size(array); i++) {
elem = nft_set_elem_alloc();
if (elem == NULL)
- goto err;
+ return -1;
json_elem = json_array_get(array, i);
if (json_elem == NULL)
- goto err;
+ return -1;
if (nft_jansson_set_elem_parse(elem,
json_elem, err) < 0)
- goto err;
+ return -1;
list_add_tail(&elem->head, &s->element_list);
}
}
- nft_jansson_free_root(tree);
return 0;
-err:
- nft_jansson_free_root(tree);
- return -1;
-
}
#endif
@@ -426,12 +421,16 @@ static int nft_set_json_parse(struct nft_set *s, 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_set(s, tree, err);
+ ret = nft_jansson_parse_set(s, tree, err);
+ nft_jansson_free_root(tree);
+
+ return ret;
#else
errno = EOPNOTSUPP;
return -1;
--
2.0.0
next prev parent reply other threads:[~2014-06-11 15:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-11 15:50 [libnftnl PATCH 0/5] Set: Do not print unset value Ana Rey
2014-06-11 15:50 ` [libnftnl PATCH 1/5] src: set: Use nft_rule_expr_set_* in the xml parsing code Ana Rey
2014-06-11 17:47 ` Pablo Neira Ayuso
2014-06-11 15:50 ` [libnftnl PATCH] tests: Use the system errors in test_xml Ana Rey
2014-06-11 17:48 ` Pablo Neira Ayuso
2014-06-11 15:50 ` [libnftnl PATCH 2/5] src: set: Do not print unset values in xml Ana Rey
2014-06-11 16:14 ` Arturo Borrero Gonzalez
2014-06-11 17:49 ` Pablo Neira Ayuso
2014-06-11 15:50 ` [libnftnl PATCH 3/5] src: set: Do not print unset values in json Ana Rey
2014-06-11 17:50 ` Pablo Neira Ayuso
2014-06-11 15:50 ` Ana Rey [this message]
2014-06-11 17:50 ` [libnftnl PATCH 4/5] src: set: Free memory in the same function that is reserved Pablo Neira Ayuso
2014-06-11 15:50 ` [libnftnl PATCH 5/5] tests: xmlfile: Test files without unset child elements in set elements Ana Rey
2014-06-11 17:51 ` 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=1402501851-22208-6-git-send-email-anarey@gmail.com \
--to=anarey@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).