BUG/MINOR: Fix memory leaks cfg_parse_peers

When memory allocation fails in cfg_parse_peers or when an error occurs
while parsing a stick-table, the temporary table and its id must be freed.

This fixes github issue #854. It should be backported as far as 2.0.
This commit is contained in:
Eric Salama 2020-09-18 11:55:17 +02:00 committed by Christopher Faulet
parent d2414a23c4
commit 1aab911017

View file

@ -884,13 +884,18 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
if (!t || !id) {
ha_alert("parsing [%s:%d]: '%s %s' : memory allocation failed\n",
file, linenum, args[0], args[1]);
free(t);
free(id);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
err_code |= parse_stick_table(file, linenum, args, t, id, id + prefix_len, curpeers);
if (err_code & ERR_FATAL)
if (err_code & ERR_FATAL) {
free(t);
free(id);
goto out;
}
stktable_store_name(t);
t->next = stktables_list;