about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2019-05-28 20:53:53 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2019-05-28 20:53:53 +0100
commit4b85edface379a3575273a2b712d80bd9420d4c9 (patch)
tree0c5a54c9348554428536898827fab71111e6634e /Src
parent3eea35d0853bddae13fa6f122669935a01618bf9 (diff)
downloadzsh-4b85edface379a3575273a2b712d80bd9420d4c9.tar.gz
zsh-4b85edface379a3575273a2b712d80bd9420d4c9.tar.xz
zsh-4b85edface379a3575273a2b712d80bd9420d4c9.zip
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.
Diffstat (limited to 'Src')
-rw-r--r--Src/pattern.c22
1 files changed, 12 insertions, 10 deletions
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
@@ -2653,16 +2665,6 @@ patmatchlen(void)
 	(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.
  *
  * Testing the tail end of a match is usually done by recursion, but