zsh-workers
 help / color / mirror / code / Atom feed
From: Andrew Waldron <a.a.w@gmx.us>
To: zsh-workers@zsh.org
Subject: Re: SegFault in stringsubst
Date: Sat, 19 Apr 2014 02:03:44 +1000	[thread overview]
Message-ID: <20140418160344.GA10455@ewok> (raw)
In-Reply-To: <140417114252.ZM22145@torch.brasslantern.com>

On Thu, 17 Apr 2014, Bart Schaefer wrote:

> Calling zerr() for this only makes sense if the surrounding code pays
> attention to errflag.  E.g. with the patch from 32552,
> 
>     function <(:) print { : }
> 
> emits an error message but defines a function named "print" anyway.
> 
> Anyone see any problems with this addition?
> 

Seems like a similar check should be made for anonymous function
arguments so that lastval will be set?


diff --git a/Src/exec.c b/Src/exec.c
index f16cfd3..36b7efa 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -4291,8 +4291,11 @@ execfuncdef(Estate state, UNUSED(int do_exec))
 	    end += *state->pc++;
 	    args = ecgetlist(state, *state->pc++, EC_DUPTOK, &htok);
 
-	    if (htok && args)
+	    if (htok && args) {
 		execsubst(args);
+		if (errflag)
+		    return lastval ? lastval : 1;
+	    }
 
 	    if (!args)
 		args = newlinklist();

--
Regards, Andrew.


  reply	other threads:[~2014-04-18 16:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-16  4:46 Andrew Waldron
2014-04-16  5:15 ` Bart Schaefer
2014-04-16  6:19   ` Andrew Waldron
2014-04-16 16:13     ` Bart Schaefer
2014-04-17  8:58       ` Peter Stephenson
2014-04-17 18:42 ` Bart Schaefer
2014-04-18 16:03   ` Andrew Waldron [this message]
2014-04-18 17:02     ` Bart Schaefer
2014-04-19 17:54       ` Bart Schaefer
2014-04-20 18:00         ` Sanity of lastval ($?) in for/select loops Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140418160344.GA10455@ewok \
    --to=a.a.w@gmx.us \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).