]> Savannah Git Hosting - gnulib.git/commitdiff
regex: pacify Coverity clean_state_log_if_needed
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 7 Dec 2021 22:34:21 +0000 (14:34 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 7 Dec 2021 22:37:55 +0000 (14:37 -0800)
Problem reported by Robbie Harwood in:
https://lists.gnu.org/r/bug-gnulib/2021-12/msg00005.html
* lib/regexec.c (clean_state_log_if_needed):
Add a DEBUG_ASSERT; this both pacifies Coverity and
will help to debug in case some other change mistakenly
causes the assertion to become false.

ChangeLog
lib/regexec.c

index d2e96eb7f70537a3449f1032c707300c8e51558a..bb3edbe44ae8a48b1a4c8ca30983ce7fadd53412 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2021-12-07  Paul Eggert  <eggert@cs.ucla.edu>
+
+       regex: pacify Coverity clean_state_log_if_needed
+       Problem reported by Robbie Harwood in:
+       https://lists.gnu.org/r/bug-gnulib/2021-12/msg00005.html
+       * lib/regexec.c (clean_state_log_if_needed):
+       Add a DEBUG_ASSERT; this both pacifies Coverity and
+       will help to debug in case some other change mistakenly
+       causes the assertion to become false.
+
 2021-12-07  Bruno Haible  <bruno@clisp.org>
 
        gettext-h: Optimize also for clang.
index 085bf27b0932371c6b806374c2a5640913aa9c13..3196708373f31d1c647194f86a25a3adc7e16421 100644 (file)
@@ -1670,6 +1670,7 @@ clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
 
   if (top < next_state_log_idx)
     {
+      DEBUG_ASSERT (mctx->state_log != NULL);
       memset (mctx->state_log + top + 1, '\0',
              sizeof (re_dfastate_t *) * (next_state_log_idx - top));
       mctx->state_log_top = next_state_log_idx;