Blame SOURCES/0356-gnulib-regexec-Resolve-unused-variable.patch

b1bcb2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b1bcb2
From: Darren Kenny <darren.kenny@oracle.com>
b1bcb2
Date: Wed, 21 Oct 2020 14:41:27 +0000
b1bcb2
Subject: [PATCH] gnulib/regexec: Resolve unused variable
b1bcb2
b1bcb2
This is a really minor issue where a variable is being assigned to but
b1bcb2
not checked before it is overwritten again.
b1bcb2
b1bcb2
The reason for this issue is that we are not building with DEBUG set and
b1bcb2
this in turn means that the assert() that reads the value of the
b1bcb2
variable match_last is being processed out.
b1bcb2
b1bcb2
The solution, move the assignment to match_last in to an ifdef DEBUG too.
b1bcb2
b1bcb2
Fixes: CID 292459
b1bcb2
b1bcb2
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
b1bcb2
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
b1bcb2
---
b1bcb2
 grub-core/gnulib/regexec.c              |  4 ++++
b1bcb2
 conf/Makefile.extra-dist                |  1 +
b1bcb2
 grub-core/gnulib-fix-unused-value.patch | 14 ++++++++++++++
b1bcb2
 3 files changed, 19 insertions(+)
b1bcb2
 create mode 100644 grub-core/gnulib-fix-unused-value.patch
b1bcb2
b1bcb2
diff --git a/grub-core/gnulib/regexec.c b/grub-core/gnulib/regexec.c
b1bcb2
index f632cd47b3a..fdc178e07a4 100644
b1bcb2
--- a/grub-core/gnulib/regexec.c
b1bcb2
+++ b/grub-core/gnulib/regexec.c
b1bcb2
@@ -879,7 +879,11 @@ re_search_internal (const regex_t *preg,
b1bcb2
 		    break;
b1bcb2
 		  if (BE (err != REG_NOMATCH, 0))
b1bcb2
 		    goto free_return;
b1bcb2
+#ifdef DEBUG
b1bcb2
+		  /* Only used for assertion below when DEBUG is set, otherwise
b1bcb2
+		     it will be over-written when we loop around.  */
b1bcb2
 		  match_last = REG_MISSING;
b1bcb2
+#endif
b1bcb2
 		}
b1bcb2
 	      else
b1bcb2
 		break; /* We found a match.  */
b1bcb2
diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
b1bcb2
index e914dfd897e..7b305bce766 100644
b1bcb2
--- a/conf/Makefile.extra-dist
b1bcb2
+++ b/conf/Makefile.extra-dist
b1bcb2
@@ -27,6 +27,7 @@ EXTRA_DIST += grub-core/genemuinit.sh
b1bcb2
 EXTRA_DIST += grub-core/genemuinitheader.sh
b1bcb2
 
b1bcb2
 EXTRA_DIST += grub-core/gnulib-fix-null-deref.diff
b1bcb2
+EXTRA_DIST += grub-core/gnulib-fix-unused-value.patch
b1bcb2
 EXTRA_DIST += grub-core/gnulib-fix-width.diff
b1bcb2
 EXTRA_DIST += grub-core/gnulib-no-abort.diff
b1bcb2
 EXTRA_DIST += grub-core/gnulib-no-gets.diff
b1bcb2
diff --git a/grub-core/gnulib-fix-unused-value.patch b/grub-core/gnulib-fix-unused-value.patch
b1bcb2
new file mode 100644
b1bcb2
index 00000000000..452a8732922
b1bcb2
--- /dev/null
b1bcb2
+++ b/grub-core/gnulib-fix-unused-value.patch
b1bcb2
@@ -0,0 +1,14 @@
b1bcb2
+--- grub-core/gnulib/regexec.c	2020-10-21 14:25:35.310195912 +0000
b1bcb2
++++ grub-core/gnulib/regexec.c	2020-10-21 14:32:07.961765604 +0000
b1bcb2
+@@ -828,7 +828,11 @@
b1bcb2
+ 		    break;
b1bcb2
+		  if (BE (err != REG_NOMATCH, 0))
b1bcb2
+ 		    goto free_return;
b1bcb2
++#ifdef DEBUG
b1bcb2
++		  /* Only used for assertion below when DEBUG is set, otherwise
b1bcb2
++		     it will be over-written when we loop around.  */
b1bcb2
+		  match_last = REG_MISSING;
b1bcb2
++#endif
b1bcb2
+ 		}
b1bcb2
+ 	      else
b1bcb2
+ 		break; /* We found a match.  */