]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: server: fix potential null gcc error in delete server
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 21 Apr 2021 09:50:26 +0000 (11:50 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 21 Apr 2021 10:02:30 +0000 (12:02 +0200)
gcc still reports a potential null pointer dereference in delete server
function event with a BUG_ON before it. Remove the misleading NULL check
in the for loop which should never happen.

This does not need to be backported.

src/server.c

index a6c67a01eb72f81abaaa382572f0ee9a36360de3..6728e111866fa04e5e4aaf8b078c3c3f77b929d6 100644 (file)
@@ -4563,12 +4563,12 @@ static int cli_parse_delete_server(char **args, char *payload, struct appctx *ap
        }
        else {
                struct server *next;
-               for (next = be->srv; next && srv != next->next; next = next->next)
-                       ;
+               for (next = be->srv; srv != next->next; next = next->next) {
+                       /* srv cannot be not found since we have already found
+                        * it with get_backend_server */
+                       BUG_ON(!next);
+               }
 
-               /* srv cannot be not found since we have already found it
-                * with get_backend_server */
-               BUG_ON(!next);
                next->next = srv->next;
        }