BUG/MINOR: mailers: Fix a memory leak when email alerts are released

An email alert contains a list of tcpcheck_rule. Each one is dynamically
allocated, just like its internal members. So, when an email alerts is freed, we
must be sure to properly free each tcpcheck_rule too.

This patch must be backported in 1.7 and 1.6.
This commit is contained in:
Christopher Faulet 2017-10-23 15:38:19 +02:00 committed by Willy Tarreau
parent 67957bd59e
commit de1a75b869

View File

@ -3038,8 +3038,14 @@ void email_alert_free(struct email_alert *alert)
if (!alert)
return;
list_for_each_entry_safe(rule, back, &alert->tcpcheck_rules, list)
list_for_each_entry_safe(rule, back, &alert->tcpcheck_rules, list) {
LIST_DEL(&rule->list);
free(rule->comment);
free(rule->string);
if (rule->expect_regex)
regex_free(rule->expect_regex);
free(rule);
}
free(alert);
}