iptcrdr.c: fix a potential double iptc_free(h)

closes #566
This commit is contained in:
Thomas Bernard 2021-09-28 22:47:05 +02:00
parent 6d8c22e82b
commit 50950a3520
No known key found for this signature in database
GPG Key ID: DB511043A31ACAAF
1 changed files with 14 additions and 11 deletions

View File

@ -627,7 +627,8 @@ get_peer_rule_by_index(int index,
}
/* delete_rule_and_commit() :
* subfunction used in delete_redirect_and_filter_rules() */
* subfunction used in delete_redirect_and_filter_rules()
* always call iptc_free(h) */
static int
delete_rule_and_commit(unsigned int index, IPTC_HANDLE h,
const char * miniupnpd_chain,
@ -853,13 +854,15 @@ delete_redirect_and_filter_rules(unsigned short eport, int proto)
break;
}
}
}
if(h)
/* in case the filter rule has not been found, delete_rule_and_commit() is not called
* so we neet to free h */
if(h)
#ifdef IPTABLES_143
iptc_free(h);
iptc_free(h);
#else
iptc_free(&h);
iptc_free(&h);
#endif
}
}
/*delete PEER rule*/
@ -961,12 +964,12 @@ delete_redirect_and_filter_rules(unsigned short eport, int proto)
break;
}
}
if (h)
#ifdef IPTABLES_143
iptc_free(h);
#else
iptc_free(&h);
#endif
if (h)
#ifdef IPTABLES_143
iptc_free(h);
#else
iptc_free(&h);
#endif
}
del_redirect_desc(eport, proto);