From bfd03c10a11b2856a1dc56a945094af340db3f09 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 5 May 2020 20:49:51 +0200 Subject: expr: objref: add nftnl_expr_objref_free() to release object name ==4876==ERROR: LeakSanitizer: detected memory leaks Direct leak of 9 byte(s) in 1 object(s) allocated from: #0 0x7f4e2c16b810 in strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3a810) #1 0x7f4e2a39906f in nftnl_expr_objref_set expr/objref.c:45 #2 0x7f4e2a39906f in nftnl_expr_objref_set expr/objref.c:35 Direct leak of 16 byte(s) in 2 object(s) allocated from: #0 0x7f4018aa0810 in strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3a810) #1 0x7f4016b660af in nftnl_expr_objref_set expr/objref.c:53 Signed-off-by: Pablo Neira Ayuso --- src/expr/objref.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/expr/objref.c b/src/expr/objref.c index 7388b18..2eb5c47 100644 --- a/src/expr/objref.c +++ b/src/expr/objref.c @@ -187,6 +187,14 @@ static int nftnl_expr_objref_snprintf_default(char *buf, size_t len, objref->imm.type, objref->imm.name); } +static void nftnl_expr_objref_free(const struct nftnl_expr *e) +{ + struct nftnl_expr_objref *objref = nftnl_expr_data(e); + + xfree(objref->imm.name); + xfree(objref->set.name); +} + static int nftnl_expr_objref_snprintf(char *buf, size_t len, uint32_t type, uint32_t flags, const struct nftnl_expr *e) @@ -206,6 +214,7 @@ struct expr_ops expr_ops_objref = { .name = "objref", .alloc_len = sizeof(struct nftnl_expr_objref), .max_attr = NFTA_OBJREF_MAX, + .free = nftnl_expr_objref_free, .set = nftnl_expr_objref_set, .get = nftnl_expr_objref_get, .parse = nftnl_expr_objref_parse, -- cgit v1.2.3