about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2017-01-03 14:43:41 +0000
committerPeter Stephenson <pws@zsh.org>2017-01-03 14:43:41 +0000
commite90a512aa600580e25617d3a7763c5f0cd5bccd2 (patch)
treecc4644d59ff1e5390935418f49ae20aad2ff4995
parent8d4c98540de9bcdba8565facc91fbc45855d27e2 (diff)
downloadzsh-e90a512aa600580e25617d3a7763c5f0cd5bccd2.tar.gz
zsh-e90a512aa600580e25617d3a7763c5f0cd5bccd2.tar.xz
zsh-e90a512aa600580e25617d3a7763c5f0cd5bccd2.zip
40265: Fix problems with pure string in patterns with Meta.
Copy instead of relying on jiggery pokery with memory reallocation.

Problem was triggering with string ending with Dash converted to -.
-rw-r--r--ChangeLog4
-rw-r--r--Src/pattern.c8
2 files changed, 5 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index f3c9c5654..bec87b8ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2017-01-03  Peter Stephenson  <p.stephenson@samsung.com>
 
+	* 40265: Src/pattern.c: fix continuing problems with Meta characters
+	in pattern that resolves to a string by copying source string.
+	Triggered by string that (correctly) turned Dash into '-'.
+
 	* Paulo Andrade: 40260: Src/prompt.c: Set newly allocated
 	space in prompt buffer to zero as it may be tested.
 
diff --git a/Src/pattern.c b/Src/pattern.c
index 1f2e94bd9..928790f45 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -668,15 +668,9 @@ patcompile(char *exp, int inflags, char **endexp)
 			    if (imeta(*mtest))
 				nmeta++;
 			if (nmeta) {
-			    char *oldpatout = patout;
-			    ptrdiff_t pd;
 			    patadd(NULL, 0, nmeta, 0);
-			    /*
-			     * Yuk.
-			     */
 			    p = (Patprog)patout;
-			    pd = patout - oldpatout;
-			    opnd += pd;
+			    opnd = dupstring_wlen(opnd, oplen);
 			    dst = patout + startoff;
 			}