From 4b85edface379a3575273a2b712d80bd9420d4c9 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Tue, 28 May 2019 20:53:53 +0100
Subject: 44361: Initialise variables in pattern matching. These are used
recursively and it's a bit obscure if there are case where the value can
leak.
---
Src/pattern.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
(limited to 'Src')
diff --git a/Src/pattern.c b/Src/pattern.c
index 737f5cdcb..97d488a31 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -2030,6 +2030,16 @@ int errsfound; /* Total error count so far */
/**/
int forceerrs; /* Forced maximum error count */
+/*
+ * exactpos is used to remember how far down an exact string we have
+ * matched, if we are doing approximation and can therefore redo from
+ * the same point; we never need to otherwise.
+ *
+ * exactend is a pointer to the end of the string, which isn't
+ * null-terminated.
+ */
+static char *exactpos, *exactend;
+
/**/
void
pattrystart(void)
@@ -2463,6 +2473,8 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
patinput = patinstart;
+ exactpos = exactend = NULL;
+ /* The only external call to patmatch --- all others are recursive */
if (patmatch((Upat)progstr)) {
/*
* we were lazy and didn't save the globflags if an exclusion
@@ -2652,16 +2664,6 @@ patmatchlen(void)
#define CHARMATCH_EXPR(expr, chpa) \
(charmatch_cache = (expr), CHARMATCH(charmatch_cache, chpa))
-/*
- * exactpos is used to remember how far down an exact string we have
- * matched, if we are doing approximation and can therefore redo from
- * the same point; we never need to otherwise.
- *
- * exactend is a pointer to the end of the string, which isn't
- * null-terminated.
- */
-static char *exactpos, *exactend;
-
/*
* Main matching routine.
*
--
cgit 1.4.1