]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: vars: always pre-initialize smp in vars_parse_cli_get_var()
authorWilly Tarreau <w@1wt.eu>
Thu, 1 Apr 2021 15:01:43 +0000 (17:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 1 Apr 2021 15:04:17 +0000 (17:04 +0200)
In issue #1200 Coverity believes we may use an uninitialized field
smp.sess here while it's not possible because the returned variable
necessarily matches SCOPE_PROC hence smp.sess is not used. But it
cannot see this and it could be confusing if the code later evolved
into something more complex. That's not a critical path so let's
first reset the sample.

src/vars.c

index cf92005f59ecd7a06b8ed8edfa79c1d32dab9c47..980b669c3a862f1648cf91dea82a4453469e567c 100644 (file)
@@ -873,7 +873,7 @@ static int vars_parse_global_set_var(char **args, int section_type, struct proxy
 static int vars_parse_cli_get_var(char **args, char *payload, struct appctx *appctx, void *private)
 {
        struct vars *vars;
-       struct sample smp;
+       struct sample smp = { };
        int i;
 
        if (!cli_has_level(appctx, ACCESS_LVL_OPER))