netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ana Rey <anarey@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: Ana Rey <anarey@gmail.com>
Subject: [libnftnl PATCH 1/5] src: table: Free memory in the same function that is reserved
Date: Thu, 26 Jun 2014 19:08:37 +0200	[thread overview]
Message-ID: <1403802521-12571-2-git-send-email-anarey@gmail.com> (raw)
In-Reply-To: <1403802521-12571-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/table.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/table.c b/src/table.c
index b4d1663..ed6e615 100644
--- a/src/table.c
+++ b/src/table.c
@@ -328,25 +328,21 @@ int nft_jansson_parse_table(struct nft_table *t, json_t *tree,
 
 	str = nft_jansson_parse_str(root, "name", err);
 	if (str == NULL)
-		goto err;
+		return -1;
 
 	nft_table_attr_set_str(t, NFT_TABLE_ATTR_NAME, str);
 
 	if (nft_jansson_parse_family(root, &family, err) != 0)
-		goto err;
+		return -1;
 
 	nft_table_attr_set_u32(t, NFT_TABLE_ATTR_FAMILY, family);
 
 	if (nft_jansson_parse_val(root, "flags", NFT_TYPE_U32, &flags, err) < 0)
-		goto err;
+		return -1;
 
 	nft_table_attr_set_u32(t, NFT_TABLE_ATTR_FLAGS, flags);
 
-	nft_jansson_free_root(tree);
 	return 0;
-err:
-	nft_jansson_free_root(tree);
-	return -1;
 }
 #endif
 
@@ -357,12 +353,17 @@ static int nft_table_json_parse(struct nft_table *t, 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_table(t, tree, err);
+	ret = nft_jansson_parse_table(t, tree, err);
+
+	nft_jansson_free_root(tree);
+
+	return ret;
 #else
 	errno = EOPNOTSUPP;
 	return -1;
-- 
2.0.0


  reply	other threads:[~2014-06-26 17:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-26 17:08 [libnftnl PATCH 0/5] Do not print unset values in xml and json Ana Rey
2014-06-26 17:08 ` Ana Rey [this message]
2014-06-26 17:08 ` [libnftnl PATCH 2/5] src: table: Use nft_table_attr_set_* in the xml functions Ana Rey
2014-06-26 17:08 ` [libnftnl PATCH 3/5] src: table: Add set, unset and parse implementation for use value Ana Rey
2014-06-26 17:08 ` [libnftnl PATCH 4/5] src: table: Do not print unset values in xml file Ana Rey
2014-06-26 17:08 ` [libnftnl PATCH 5/5] src: table: Do not print unset values in json file Ana Rey
2014-06-30 10:49 ` [libnftnl PATCH 0/5] Do not print unset values in xml and json 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=1403802521-12571-2-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).