]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
regex: Fix use of uninitialized variable (regression yesterday).
authorBruno Haible <bruno@clisp.org>
Mon, 13 Apr 2026 15:14:26 +0000 (17:14 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 13 Apr 2026 15:15:25 +0000 (17:15 +0200)
Reported by Coverity.

* lib/regexec.c (re_search_internal): Move initialization of variable
'save_state_log' further up.

ChangeLog
lib/regexec.c

index 3860cadfd1d703cfad26844a3feef68feb70329c..875e73465780bf06377cdd3a1aae6dfeb8109360 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-04-13  Bruno Haible  <bruno@clisp.org>
+
+       regex: Fix use of uninitialized variable (regression yesterday).
+       Reported by Coverity.
+       * lib/regexec.c (re_search_internal): Move initialization of variable
+       'save_state_log' further up.
+
 2026-04-12  Jim Meyering  <meyering@meta.com>
 
        regex: small simplification
index 259dfd36c64510da67b85de28c094111ec618bea..7095c4bf5b235321a851bcd4b146138d40dcb033 100644 (file)
@@ -627,6 +627,8 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
   /* We must check the longest matching, if nmatch > 0.  */
   fl_longest_match = (nmatch != 0 || dfa->nbackref);
 
+  re_dfastate_t **save_state_log = NULL;
+
   err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1,
                            preg->translate, (preg->syntax & RE_ICASE) != 0,
                            dfa);
@@ -678,8 +680,6 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
        | (t != NULL ? 1 : 0))
      : 8);
 
-  re_dfastate_t **save_state_log = NULL;
-
   for (;; match_first += incr)
     {
       err = REG_NOMATCH;