Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] jp: fix segfaults during parameter expansion
- X-seq: zsh-workers 42308
- From: Joey Pabalinas <joeypabalinas@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: [PATCH] jp: fix segfaults during parameter expansion
- Date: Sat, 20 Jan 2018 15:47:58 -1000
- Cc: zsh-workers@xxxxxxx, Daniel Tameling <tamelingdaniel@xxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=UPzFb4qtwERZ0GuySMffYv7coipQOAVZF7kNXysvXJw=; b=JaP8y4FBh/e5ihd3/tMgAoZbj/Upwc8jjhCAhPolTX1Kl9Nzj6eHxZFzEQk6OYQk77 sNRSB36GQnEihG4RKLLrIRM7E8yur/vR+vPQZMYYSCn0TaNwrG1toVOZSiIXhUzkM4ay URpy/FLYl7jTpwIdX0Dm+rYfs4bChdYW7m+5sE67rQ2PI/2k5FtHWhsWt7fcM8lDKyQc nUSNq1YbSAGtaJn6pkss5Hzb+Qjri1m+FZFE1qyVnt6Tul/u7WDior9/mXv0SzIc0QoP JiF8/aSUUku0UBjQTAol/ntiCpDTpJNo3FX6spTR7zW+59gS7WpBjSXWms6+1doyNqgC f8Jg==
- In-reply-to: <180120160304.ZM12968@torch.brasslantern.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> <CAH+w=7bMF_Kzvme+5EVazsa2KKEHO2uh2-u_T0MSAx2H=zcXQg@mail.gmail.com> <m2fu705wuy.fsf@gmail.com> <180120160304.ZM12968@torch.brasslantern.com>
Running:
> $ zsh -fc ': ${${(PAA)p[foo]}::=x}'` in current zsh versions causes:
>
> [1] 4441 segmentation fault (core dumped) zsh -fc ': ${${(PAA)p[foo]}::=x}'
Also happens when testing with machabot:
> 19:42 <jp> > : ${${(PAA)p[foo]}::=x}
> 19:42 <machabot> jp: zsh[248]: segfault at 0 ip b7dfcda3 sp bfeb9ebc
> error 4 in libc-2.13.so[b7d84000+149000]
Add a simple `dupstring(s)` fallback.
Signed-off-by: Joey Pabalinas <joeypabalinas@xxxxxxxxx>
Requested-by: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Src/subst.c b/Src/subst.c
index d027e3d83cadc631a7..d159a92ae1bc1b9c10 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2423,14 +2423,14 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
* substitution.
*/
if (isarr) {
- if (aval[0] && aval[1]) {
+ if (!aval[0] || (aval[0] && aval[1])) {
zerr("parameter name reference used with array");
return NULL;
}
val = aval[0];
isarr = 0;
}
- s = dyncat(val, s);
+ s = val ? dyncat(val, s) : dupstring(s);
/* Now behave po-faced as if it was always like that... */
subexp = 0;
/*
--
2.16.0
Incorpated your changes, although I feel like the conditional operator is
a better fit here (simpler and much more concise; making each possibility a
lone function call is one of the few uses of `?:` where the intent is
flat-out obvious).
Tested and works great:
> $ : ${${(PAA)p[foo]}::=x}
>
> zsh: parameter name reference used with array
--
Joey Pabalinas
Attachment:
signature.asc
Description: PGP signature
Messages sorted by:
Reverse Date,
Date,
Thread,
Author