From 12df33fed758c4cb71b8ae38b973657ca941faec Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 7 Dec 2021 14:34:21 -0800 Subject: [PATCH] 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. --- ChangeLog | 10 ++++++++++ lib/regexec.c | 1 + 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index d2e96eb7f7..bb3edbe44a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2021-12-07 Paul Eggert + + 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 gettext-h: Optimize also for clang. diff --git a/lib/regexec.c b/lib/regexec.c index 085bf27b09..3196708373 100644 --- a/lib/regexec.c +++ b/lib/regexec.c @@ -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; -- 2.33.1