]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
set: free user data
authorEric Leblond <eric@regit.org>
Thu, 6 Jul 2017 12:58:27 +0000 (13:58 +0100)
committerEric Leblond <eric@regit.org>
Thu, 6 Jul 2017 12:58:27 +0000 (13:58 +0100)
This was causing a memory leak when using set.

Catched by an ASAN run:

==21004==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 12 byte(s) in 2 object(s) allocated from:
    #0 0x4cde58 in malloc (/usr/local/sbin/nft+0x4cde58)
    #1 0x7ffff79b8c19 in nftnl_set_set_data /home/eric/git/netfilter/libnftnl/src/set.c:179

src/set.c

index cce5e639b6dd6fc9eb6dc6617aec4ed4671e1cd1..1158e385d88212a3d213bf7d539540e5ceb3f598 100644 (file)
--- a/src/set.c
+++ b/src/set.c
@@ -48,6 +48,8 @@ void nftnl_set_free(const struct nftnl_set *s)
                xfree(s->table);
        if (s->flags & (1 << NFTNL_SET_NAME))
                xfree(s->name);
+       if (s->flags & (1 << NFTNL_SET_USERDATA))
+               xfree(s->user.data);
 
        list_for_each_entry_safe(elem, tmp, &s->element_list, head) {
                list_del(&elem->head);