Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Sigsegv on empty array intersection/subtraction
On Sat, 16 Nov 2013 21:48:26 +0000
Charles Daffern <seejay.11@xxxxxxxxx> wrote:
> ${:*}
> ${:|}
>
> The missing first parameter in these expressions causes a segmentation
> fault. I'm using zsh 5.0.2 (x86_64-unknown-linux-gnu).
The following repeats a chunk in the other branch of the "if", but there
isn't an obvious common place to put it without the risk of subtle
changes of behaviour.
diff --git a/Src/subst.c b/Src/subst.c
index a4df256..1059508 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2941,6 +2941,14 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
}
}
}
+ if (vunset) {
+ if (unset(UNSET)) {
+ *idend = '\0';
+ zerr("%s: parameter not set", idbeg);
+ return NULL;
+ }
+ val = dupstring("");
+ }
} else { /* no ${...=...} or anything, but possible modifiers. */
/*
* Handler ${+...}. TODO: strange, why do we handle this only
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index bea9459..f72a3d6 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -1551,3 +1551,12 @@
0:Empty parameter shouldn't cause modifiers to crash the shell
>
>
+
+# This used to cause uncontrolled behaviour, but at best
+# you got the wrong output so the check is worth it.
+ args() { print $#; }
+ args ${:*}
+ args ${:|}
+0:Intersection and disjunction with empty parameters
+>0
+>0
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author