bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/3] lib/regexec: Resolve unused variable


From: Darren Kenny
Subject: [PATCH 3/3] lib/regexec: Resolve unused variable
Date: Fri, 18 Jun 2021 15:44:23 +0000

This is a fairly minor issue where a variable is being assigned to but
not checked before it is overwritten again.

The reason for this issue is that we are not building with DEBUG set and
this in turn means that the assert() that reads the value of the
variable match_last is being processed out.

The solution, move the assignment to match_last in to an ifdef DEBUG too.

This was originally found during a Coverity scan of GRUB2.

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
---
 lib/regexec.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/regexec.c b/lib/regexec.c
index 2b2ab8e4afd0..ed3fa43bd0d1 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -816,7 +816,11 @@ re_search_internal (const regex_t *preg, const char 
*string, Idx length,
                    break;
                  if (__glibc_unlikely (err != REG_NOMATCH))
                    goto free_return;
+#ifdef DEBUG
+                 /* Only used for assertion below when DEBUG is set, otherwise
+                    it will be over-written when we loop around.  */
                  match_last = -1;
+#endif
                }
              else
                break; /* We found a match.  */
-- 
2.18.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]