]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: uri-auth: never risk to dereference a NULL on error path
authorWilly Tarreau <w@1wt.eu>
Fri, 14 Aug 2026 15:48:14 +0000 (17:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 14 Aug 2026 15:50:31 +0000 (17:50 +0200)
The fix in commit 2dfbc311a8 ("BUG/MINOR: uri-auth: avoid leaks on
initialization error") added *root = NULL, but the functions support
being called with root == NULL, though nothing does it in the whole
code. At least it triggers Coverity (see github issue #3476 and #3477).
So let's fix it.

No backport is needed since it cannot happen in the current code base.

src/uri_auth.c

index db1d83dc5bd404377690c4f015dadd3e4e34fa83..448cd46c6ac0dcc69133867d3c612894223e3259 100644 (file)
@@ -275,7 +275,8 @@ struct uri_auth *stats_add_auth(struct uri_auth **root, char *user)
                        free(u->userlist);
                }
                free(u);
-               *root = NULL;
+               if (root)
+                       *root = NULL;
        }
        return NULL;
 }
@@ -320,7 +321,8 @@ struct uri_auth *stats_add_scope(struct uri_auth **root, char *scope)
  out_u:
        if (!old_u) {
                free(u);
-               *root = NULL;
+               if (root)
+                       *root = NULL;
        }
  out:
        return NULL;