From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH libnftnl] expr: objref: add nftnl_expr_objref_free() to release object name
Date: Tue, 5 May 2020 20:50:47 +0200 [thread overview]
Message-ID: <20200505185047.12487-1-pablo@netfilter.org> (raw)
==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
reply other threads:[~2020-05-05 18:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200505185047.12487-1-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).