summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2021-06-11 16:43:21 +0200
committerPhil Sutter <phil@nwl.cc>2021-06-14 13:31:07 +0200
commitaccd7a346fd19f1ffc503b3f681323abf1157c1a (patch)
tree211bc50be6aac4cf4d03c087b2960dbd393056f4
parentc1616dfd1ce40bac197924c8947e1c646e915dca (diff)
netlink: Avoid memleak in error path of netlink_delinearize_set()
Duplicate string 'comment' later when the function does not fail anymore. Fixes: 0864c2d49ee8a ("src: add comment support for set declarations") Signed-off-by: Phil Sutter <phil@nwl.cc>
-rw-r--r--src/netlink.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/netlink.c b/src/netlink.c
index e91b06e3..41cce337 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -867,7 +867,7 @@ struct set *netlink_delinearize_set(struct netlink_ctx *ctx,
if (ud[NFTNL_UDATA_SET_DATA_TYPEOF])
typeof_expr_data = set_make_key(ud[NFTNL_UDATA_SET_DATA_TYPEOF]);
if (ud[NFTNL_UDATA_SET_COMMENT])
- comment = xstrdup(nftnl_udata_get(ud[NFTNL_UDATA_SET_COMMENT]));
+ comment = nftnl_udata_get(ud[NFTNL_UDATA_SET_COMMENT]);
}
key = nftnl_set_get_u32(nls, NFTNL_SET_KEY_TYPE);
@@ -905,7 +905,7 @@ struct set *netlink_delinearize_set(struct netlink_ctx *ctx,
set->handle.set.name = xstrdup(nftnl_set_get_str(nls, NFTNL_SET_NAME));
set->automerge = automerge;
if (comment)
- set->comment = comment;
+ set->comment = xstrdup(comment);
init_list_head(&set_parse_ctx.stmt_list);