From: Christian Marangi Date: Mon, 29 May 2023 12:46:49 +0000 (+0200) Subject: iptables: free xtables_match if found in need_protomatch X-Git-Url: http://git.openwrt.org/?p=project%2Ffirewall3.git;a=commitdiff_plain;h=ffba75c9cd8f96ef34b7b3ab35315ce66ba8f37d 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 --- 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; }