From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4602 invoked by alias); 17 Nov 2013 20:30:31 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32001 Received: (qmail 11771 invoked from network); 17 Nov 2013 20:30:16 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=VAtjvsg5oYqIIRX0Mbb1hM5W4NEDqEQyFUTnMBE+C9U=; b=TTGjMqBu7PPSHcsrtLoRALvL1PQ34QeGL2dqakniDW3lE0gF4fkQcARTF6MWteYdBm 2NdEGDYrwk68wd+TDQYAY8USuz/RfaDTZh1Woa0I9AhEin+Hypb5nNkvme+b22l3T7p6 4zCOgeFuOnYjIYmZK4wQinWxVjuim9fScpE2YYig8SvavwGGySyzzrDMWfEXXsWRbeYc aWgyFqV9p4nOi3vOXrwBdQ2TCFd2ighjruyk0oZ+P7/H5H8wVupA/XdI2SKnxXluHbV7 FTqQOUUF4Nw9iOYmKNO32lXnoVklN+iHQDoOM/YIYUJFavphHdA3OrHG1SahOYeM61+w M6VA== X-Gm-Message-State: ALoCoQlvbuwRcFEiBOXnaWzB7MsoGSHmo+JzV/xLPHK4H0lr1IB7IReWrZxY0SH0li9jh+Fm1jyW X-Received: by 10.180.73.70 with SMTP id j6mr14009972wiv.47.1384718522496; Sun, 17 Nov 2013 12:02:02 -0800 (PST) X-ProxyUser-IP: 86.6.157.246 Date: Sun, 17 Nov 2013 20:01:59 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: Sigsegv on empty array intersection/subtraction Message-ID: <20131117200159.5e731254@pws-pc.ntlworld.com> In-Reply-To: <5287E82A.5080602@gmail.com> References: <5287E82A.5080602@gmail.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 16 Nov 2013 21:48:26 +0000 Charles Daffern 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 Web page now at http://homepage.ntlworld.com/p.w.stephenson/