]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: fix a segfault when parsing a config with undeclared peers
authorWilly Tarreau <w@1wt.eu>
Fri, 28 Oct 2011 12:16:49 +0000 (14:16 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 28 Oct 2011 12:16:49 +0000 (14:16 +0200)
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.

src/cfgparse.c

index 5ddfbe26fed09b97d09b2358086c065266420c65..bf761857c1c1e6d5d7a0c29b44acee8f5b934570 100644 (file)
@@ -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++;
                        }
                }