From a5c387def7981fd5b2e48759d3d1ca489cdfefcf Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Wed, 14 Aug 2013 11:10:58 +0200 Subject: src: xml: don't duplicate string in nft_table_xml_parse With this patch, nft_table_xml_parse does not duplicate the string anymore, which is what most callers seem to need. This fixes memleaks in several places in the code. Thus, this patch also adapts the code to duplicate it when needed. Based on patch from Arturo Borrero. Signed-off-by: Pablo Neira Ayuso --- src/rule.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/rule.c') diff --git a/src/rule.c b/src/rule.c index 4b5ffa6..c3cdb84 100644 --- a/src/rule.c +++ b/src/rule.c @@ -514,7 +514,7 @@ static int nft_rule_xml_parse(struct nft_rule *r, char *xml) if (r->table) xfree(r->table); - r->table = table; + r->table = strdup(table); r->flags |= (1 << NFT_RULE_ATTR_TABLE); chain = nft_mxml_str_parse(tree, "chain", MXML_DESCEND_FIRST); @@ -526,7 +526,7 @@ static int nft_rule_xml_parse(struct nft_rule *r, char *xml) if (r->chain) xfree(r->chain); - r->chain = chain; + r->chain = strdup(chain); r->flags |= (1 << NFT_RULE_ATTR_CHAIN); if (nft_mxml_num_parse(tree, "handle", MXML_DESCEND_FIRST, BASE_DEC, -- cgit v1.2.3