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@xxxxxx> --- src/netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/netlink.c b/src/netlink.c index e91b06e3ea971..41cce3379ca50 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); -- 2.31.1