]> git.kaiwu.me - haproxy.git/commitdiff
CLEANUP: regex: pre-initialize error variable in regex_comp() to calm analysis master
authorWilly Tarreau <w@1wt.eu>
Mon, 11 May 2026 15:29:56 +0000 (17:29 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 11 May 2026 15:29:56 +0000 (17:29 +0200)
In regex_comp(), the error variable is either a const char* (USE_PCRE)
or a a uchar[] (USE_PCRE2), and navigating through the ifdefs is quite a
mess, making it hard to figure if it's always properly initialized when
printing an error message. Let's just preset it to NULL to clarify what
comes from where.

src/regex.c

index c9d5258c418b179554a6f6fc6c64e30f9215a04a..524afc92574b694d6757cd0e95da6315100bbc04 100644 (file)
@@ -304,7 +304,7 @@ struct my_regex *regex_comp(const char *str, int cs, int cap, char **err)
        struct my_regex *regex = NULL;
 #if defined(USE_PCRE) || defined(USE_PCRE_JIT)
        int flags = 0;
        struct my_regex *regex = NULL;
 #if defined(USE_PCRE) || defined(USE_PCRE_JIT)
        int flags = 0;
-       const char *error;
+       const char *error = NULL;
        int erroffset;
 #elif defined(USE_PCRE2) || defined(USE_PCRE2_JIT)
        int flags = 0;
        int erroffset;
 #elif defined(USE_PCRE2) || defined(USE_PCRE2_JIT)
        int flags = 0;