about summary refs log tree commit diff
path: root/Src/subst.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2013-01-22 16:28:58 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2013-01-22 16:28:58 +0000
commit44757a653cb547ae7b556e8c92629d296d3c1f12 (patch)
tree78e92732187aec860cce73a54a3d737c50b25df2 /Src/subst.c
parent27c5a0d7744ffeaf677b097adbe9a094a3a49025 (diff)
downloadzsh-44757a653cb547ae7b556e8c92629d296d3c1f12.tar.gz
zsh-44757a653cb547ae7b556e8c92629d296d3c1f12.tar.xz
zsh-44757a653cb547ae7b556e8c92629d296d3c1f12.zip
30993: fix parameter modifier crash with :wq on empty string
Diffstat (limited to 'Src/subst.c')
-rw-r--r--Src/subst.c10
1 files changed, 9 insertions, 1 deletions
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) {