]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: backend: check srv_conn before dereferencing it
authorWilly Tarreau <w@1wt.eu>
Fri, 1 Feb 2019 15:38:48 +0000 (16:38 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 Feb 2019 15:47:46 +0000 (16:47 +0100)
Commit 3c4e19f42 ("BUG/MEDIUM: backend: always release the previous
connection into its own target srv_list") introduced a valid warning
about a null-deref risk since we didn't check conn_new()'s return value.

This patch must be backported to 1.9 with the patch above.

src/backend.c

index 4340ba58a1d1d80ac092a883317f1f7c942d60b9..eac41544774522b30bb41f0049f67b5f9fa497fa 100644 (file)
@@ -1343,7 +1343,8 @@ int connect_server(struct stream *s)
        /* no reuse or failed to reuse the connection above, pick a new one */
        if (!srv_conn) {
                srv_conn = conn_new();
-               srv_conn->target = s->target;
+               if (srv_conn)
+                       srv_conn->target = s->target;
                srv_cs = NULL;
        }