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

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