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.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 9d8ef65..768fea3 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -884,13 +884,18 @@
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;