netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH libnftnl] expr: objref: add nftnl_expr_objref_free() to release object name
@ 2020-05-05 18:50 Pablo Neira Ayuso
  0 siblings, 0 replies; only message in thread
From: Pablo Neira Ayuso @ 2020-05-05 18:50 UTC (permalink / raw)
  To: netfilter-devel

==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

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/expr/objref.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/expr/objref.c b/src/expr/objref.c
index 7388b18ac929..d3dd17ee788c 100644
--- a/src/expr/objref.c
+++ b/src/expr/objref.c
@@ -187,6 +187,13 @@ 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);
+}
+
 static int nftnl_expr_objref_snprintf(char *buf, size_t len, uint32_t type,
 				      uint32_t flags,
 				      const struct nftnl_expr *e)
@@ -206,6 +213,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,
-- 
2.20.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-05 18:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 18:50 [PATCH libnftnl] expr: objref: add nftnl_expr_objref_free() to release object name Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).