From ffba75c9cd8f96ef34b7b3ab35315ce66ba8f37d Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Mon, 29 May 2023 14:46:49 +0200 Subject: [PATCH] iptables: free xtables_match if found in need_protomatch Fix Coverity Scan ID 1529284 by freeing the xtables_match from xtables_find_match if found. Signed-off-by: Christian Marangi --- iptables.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/iptables.c b/iptables.c index 49b3439..83308ec 100644 --- a/iptables.c +++ b/iptables.c @@ -709,12 +709,16 @@ init_match(struct fw3_ipt_rule *r, struct xtables_match *m, bool no_clone) static bool need_protomatch(struct fw3_ipt_rule *r, const char *pname) { + struct xtables_match *match; + if (!pname) return false; - if (!xtables_find_match(pname, XTF_DONT_LOAD, NULL)) + match = xtables_find_match(pname, XTF_DONT_LOAD, NULL); + if (!match) return true; + free(match); return !r->protocol_loaded; } -- 2.30.2