From 92ec4d05ab7e4a97db043ec6306ebce74ee3d0ad Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Mon, 8 Jun 2020 10:08:44 +0200 Subject: [PATCH] nftnlrdr_misc.c: fix a memory leak in table_cb() --- miniupnpd/netfilter_nft/nftnlrdr_misc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/miniupnpd/netfilter_nft/nftnlrdr_misc.c b/miniupnpd/netfilter_nft/nftnlrdr_misc.c index cf334e1..362c960 100644 --- a/miniupnpd/netfilter_nft/nftnlrdr_misc.c +++ b/miniupnpd/netfilter_nft/nftnlrdr_misc.c @@ -497,7 +497,6 @@ table_cb(const struct nlmsghdr *nlh, void *data) { int result = MNL_CB_OK; struct nftnl_rule *rule; - struct nftnl_expr *expr; struct nftnl_expr_iter *itr; UNUSED(data); @@ -556,9 +555,16 @@ table_cb(const struct nlmsghdr *nlh, void *data) } itr = nftnl_expr_iter_create(rule); + if (itr == NULL) { + syslog(LOG_ERR, "%s: nftnl_expr_iter_create() FAILED", + "table_cb"); + } else { + struct nftnl_expr *expr; - while ((expr = nftnl_expr_iter_next(itr)) != NULL) { - rule_expr_cb(expr, r); + while ((expr = nftnl_expr_iter_next(itr)) != NULL) { + rule_expr_cb(expr, r); + } + nftnl_expr_iter_destroy(itr); } switch (r->type) {