Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: SegFault in stringsubst



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.



Messages sorted by: Reverse Date, Date, Thread, Author