From: Willy Tarreau Date: Fri, 28 Oct 2011 12:16:49 +0000 (+0200) Subject: BUG/MINOR: fix a segfault when parsing a config with undeclared peers X-Git-Tag: v1.5-dev8~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d66bf96d5b0eff5960aa1c00bccd2e3893a3c731;p=thirdparty%2Fhaproxy.git BUG/MINOR: fix a segfault when parsing a config with undeclared peers Baptiste Assmann reported that a config where a non-existing peers section is referenced by a stick-table causes a segfault after displaying the error. This is caused by the freeing of the peers. Setting it to NULL after displaying the error fixes the issue. --- diff --git a/src/cfgparse.c b/src/cfgparse.c index 5ddfbe26fe..bf761857c1 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -5884,11 +5884,15 @@ int check_config_validity() if (!curpeers) { Alert("Proxy '%s': unable to find sync peers '%s'.\n", curproxy->id, curproxy->table.peers.name); + free((void *)curproxy->table.peers.name); + curproxy->table.peers.p = NULL; cfgerr++; } else if (!curpeers->peers_fe) { Alert("Proxy '%s': unable to find local peer '%s' in peers section '%s'.\n", curproxy->id, localpeer, curpeers->id); + free((void *)curproxy->table.peers.name); + curproxy->table.peers.p = NULL; cfgerr++; } }