Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] jp: fix segfaults during parameter expansion
- X-seq: zsh-workers 42302
- From: Daniel Tameling <tamelingdaniel@xxxxxxxxx>
- To: "zsh-workers\@zsh.org" <zsh-workers@xxxxxxx>
- Subject: Re: [PATCH] jp: fix segfaults during parameter expansion
- Date: Sat, 20 Jan 2018 17:16:37 +0100
- Cc:
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=ZFEXZKtjC/Y/No3yHU64LpJUF2pJ+3swKHqIKIMccCc=; b=JQpymuRAu+AD0Q0Ck3qN9B9sivqgtnp9VjpYs/Si4Fsk0/DfsvbD3pduUUPwGB19Tz he+nKqAONRING+SiyaGtDX6IhC65tx+nqhLfsgqmUiVQPy0UgR33+eco5NNlr0XebZns zSnHh/yGgJj6ChxA6i8c0k7sBDzs7EyzlqTIK5tsjr79CGWbqbIbxBtVD54oaBOS2ZvI RStB0ndOCjmhjThtvVGnn7v9ZTvNWx9ojSVCgx2FrriB4nDEpmounhH/j/Lxbsy+uoTa nVX2GkA8anMpTJg9l72brP4lQQUieXNaQMAySIX18nFeV5LOUebyi84/5qQxEWbB7WVL UuAQ==
- In-reply-to: <CAH+w=7bMF_Kzvme+5EVazsa2KKEHO2uh2-u_T0MSAx2H=zcXQg@mail.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> <CAH+w=7bMF_Kzvme+5EVazsa2KKEHO2uh2-u_T0MSAx2H=zcXQg@mail.gmail.com>
Hi,
while working through my email backlog, I noticed that my zsh didn't
segfault. I used git bisect, and it looks like commit
4b8db48c6bd3c0230a5d81f49e478857adf9cda8 introduced it. Maybe this helps
someone that understands the code base better than me to figure out
what's wrong.
Kind regards
Daniel
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> writes:
> 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;
> /*
--
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author