Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] jp: fix segfaults during parameter expansion
- X-seq: zsh-workers 42268
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: [PATCH] jp: fix segfaults during parameter expansion
- Date: Sun, 14 Jan 2018 04:06:09 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=nLRogzKp3g9Q06O9Q80OtV8woqp5qBXLdL1UPedDi58=; b=L7plr++nC3gdW9RS+0svaQDGmHF+KFoMzJspE+5eLq0vkBIVNVgAwtVYGZSz28zRKB BFuFa5aG2yKsHh5ZM5TOC7BZJLNg9kPnF1DiC/UH9aVFDmxDULse5BbjeobSh3ZmOqZs hncTroLWO7Vrw1c1HvAL+1sJyTg6ReLHr7MOLomXN2ZUlULyVb5ER4UGjy2O28t8nM2B YeSMMttIWaALsGj4CjGmvmRYtwtjZPq/soUsxfMRYUEbSLWo/YbNrmFq8JVqu06ZTAb5 byPTif7Vxd4lg8g7CiKOzVSESGk2iDvNRdLTuiLvEb4FXpYa4DVEyr/mcYCY1/sm/nau x94w==
- In-reply-to: <20180114060557.hmrvpg6t4rdebgv6@gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20180114060557.hmrvpg6t4rdebgv6@gmail.com>
On Sat, Jan 13, 2018 at 10:05 PM, Joey Pabalinas
<joeypabalinas@xxxxxxxxx> wrote:
> Running `zsh -fc ': ${${(PAA)p[foo]}::=x}'` in current zsh versions causes:
>
>> "segmentation fault (core dumped) zsh -fc '(: ${${(PAA)p[foo]}::=x})'
>
> Add checks to catch NULL dereferences.
Thanks for tracking this down. Defensive programming is always good,
but I think this is indicative of a problem further upstream.
What's the expected output of that substitution?
The following prevents the segfault for me, instead giving the error
"zsh: not an identifier: " (i.e., empty string is not a valid
parameter name). But perhaps there's a different error that should
occur here if val is NULL?
diff --git a/Src/subst.c b/Src/subst.c
index d027e3d..73491c2 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2430,7 +2430,10 @@ paramsubst(LinkList l, LinkNode n, char **str,
int qt, int pf_flags,
val = aval[0];
isarr = 0;
}
- s = dyncat(val, s);
+ if (val)
+ s = dyncat(val, s);
+ else
+ s = dupstring(s);
/* Now behave po-faced as if it was always like that... */
subexp = 0;
/*
Messages sorted by:
Reverse Date,
Date,
Thread,
Author