]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
netlink: fix memory leaks
authorPatrick McHardy <kaber@trash.net>
Sun, 11 Jan 2015 07:54:55 +0000 (07:54 +0000)
committerPatrick McHardy <kaber@trash.net>
Sun, 11 Jan 2015 07:54:55 +0000 (07:54 +0000)
Fix two memory leaks in netlink event monitor. Also fix a leak related
to all sets, the ->init expression is not freed.

Signed-off-by: Patrick McHardy <kaber@trash.net>
src/netlink.c
src/rule.c

index feaea19af0d09f95c8ae316725a1ce1993008a5b..534737295fb4a1595f6b36cef3bcfd439893d99b 100644 (file)
@@ -1724,8 +1724,10 @@ static int netlink_events_set_cb(const struct nlmsghdr *nlh, int type,
                case NFT_MSG_NEWSET:
                        printf("add ");
                        set = netlink_delinearize_set(monh->ctx, nls);
-                       if (set == NULL)
+                       if (set == NULL) {
+                               nft_set_free(nls);
                                return MNL_CB_ERROR;
+                       }
                        set_print_plain(set);
                        set_free(set);
                        printf("\n");
@@ -1940,6 +1942,7 @@ static void netlink_events_cache_addset(struct netlink_mon_handler *monh,
        t = table_lookup(&s->handle);
        if (t == NULL) {
                fprintf(stderr, "W: Unable to cache set: table not found.\n");
+               set_free(s);
                goto out;
        }
 
index 95766646db8ec595d123bcd44ddc5cdfadca4858..dd39e8ae6b8928215794dc16c6849b719f36ba01 100644 (file)
@@ -74,6 +74,8 @@ void set_free(struct set *set)
 {
        if (--set->refcnt > 0)
                return;
+       if (set->init != NULL)
+               expr_free(set->init);
        handle_free(&set->handle);
        xfree(set);
 }