]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: mworker: always initialize the saveptr of strtok_r()
authorWilly Tarreau <w@1wt.eu>
Wed, 25 Dec 2024 11:10:13 +0000 (12:10 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 25 Dec 2024 11:18:46 +0000 (12:18 +0100)
Building with some libcs which define strtok_r() as an inline function
can yield a possibly uninitialized warning due to a loop dereferencing
this save pointer early, even though the doc clearly mentions that it
is ignored. This is actually more of a mismatch between the compiler
and the libc (gcc-4.7 and glibc-2.23 in that case). It's trivial to
set s2 to NULL here so let's do it to please this old couple. Note
that while the warning is triggered in all supported versions, there's
no point backporting it since it's unlikely this combination will be
relevant outside of backwards compatibility checks now.

src/mworker.c

index 9096f0062805733e03eeff541c0f430b02b4c0dd..2cf1884947c8cf4a1d4708084d0cf0922b4632ec 100644 (file)
@@ -175,7 +175,7 @@ int mworker_env_to_proc_list()
 
        while ((token = strtok_r(msg, "|", &s1))) {
                char *subtoken = NULL;
-               char *s2;
+               char *s2 = NULL;
 
                msg = NULL;