From 50b175dbd598e80a0e67606645d1fa3c9be6ce01 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 10 Jun 2016 16:45:48 +0200 Subject: src: check for flags before releasing attributes Now that unsetters don't set pointers to NULL, check if the attribute is set before trying to release it. Signed-off-by: Pablo Neira Ayuso --- src/table.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/table.c') diff --git a/src/table.c b/src/table.c index 412c6aa..32d119f 100644 --- a/src/table.c +++ b/src/table.c @@ -89,7 +89,7 @@ int nftnl_table_set_data(struct nftnl_table *t, uint16_t attr, switch (attr) { case NFTNL_TABLE_NAME: - if (t->name) + if (t->flags & (1 << NFTNL_TABLE_NAME)) xfree(t->name); t->name = strdup(data); @@ -227,7 +227,8 @@ int nftnl_table_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_table *t) return -1; if (tb[NFTA_TABLE_NAME]) { - xfree(t->name); + if (t->flags & (1 << NFTNL_TABLE_NAME)) + xfree(t->name); t->name = strdup(mnl_attr_get_str(tb[NFTA_TABLE_NAME])); if (!t->name) return -1; -- cgit v1.2.3