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

Re: SegFault in stringsubst



On Apr 16,  2:46pm, Andrew Waldron wrote:
}
} There is also a segfault if you accidentally use process substitution
} for a function name:
} "function <(:) print" segfaults
} "function <(:) {:}" does not segfault.

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?

diff --git a/Src/exec.c b/Src/exec.c
index f16cfd3..d821d16 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2346,7 +2346,7 @@ execsubst(LinkList strs)
 {
     if (strs) {
 	prefork(strs, esprefork);
-	if (esglob) {
+	if (esglob && !errflag) {
 	    LinkList ostrs = strs;
 	    globlist(strs, 0);
 	    strs = ostrs;
@@ -4234,8 +4241,11 @@ execfuncdef(Estate state, UNUSED(int do_exec))
     plen = nprg * sizeof(wordcode);
     len = plen + (npats * sizeof(Patprog)) + nstrs;
 
-    if (htok && names)
+    if (htok && names) {
 	execsubst(names);
+	if (errflag)
+	    return 1;
+    }
 
     while (!names || (s = (char *) ugetnode(names))) {
 	if (!names) {

-- 
Barton E. Schaefer



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