summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--Src/subst.c10
-rw-r--r--Test/D04parameter.ztst7
3 files changed, 23 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index cfad073d7..e984c0288 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-01-22  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* 30993: Src/subst.c, Test/D04parameter.ztst: parameter
+	modifiers :wq operating on an empty string crashed the shell.
+	The shell isn't supposed to crash.
+
 2013-01-20  Oliver Kiddle <opk@zsh.org>
 
 	* 30987: Completion/X/Command/_xrandr: only call xrandr when
@@ -455,5 +461,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5787 $
+* $Revision: 1.5788 $
 *****************************************************
diff --git a/Src/subst.c b/Src/subst.c
index 974a8456d..a4df2567f 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -3707,6 +3707,11 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
 	char *y;
 
 	x = val;
+	if (!x) {
+	    /* Shouldn't have got here with a NULL string. */
+	    DPUTS(1, "value is NULL in paramsubst");
+	    return NULL;
+	}
 	if (prenum || postnum)
 	    x = dopadding(x, prenum, postnum, preone, postone,
 			  premul, postmul
@@ -4021,7 +4026,10 @@ modify(char **str, char **ptr)
 		    all = tmp;
 		    t = e;
 		}
-		*str = all;
+		if (!all)
+		    *str = dupstring("");
+		else
+		    *str = all;
 
 	    } else {
 		switch (c) {
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 01f841218..bea945971 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -1544,3 +1544,10 @@
 0:Regression test for shwordsplit with null or unset IFS and quoted array
 >abc
 >a b c
+
+   foo=
+   print ${foo:wq}
+   print ${:wq}
+0:Empty parameter shouldn't cause modifiers to crash the shell
+>
+>