Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: SegFault in stringsubst
- X-seq: zsh-workers 32560
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: SegFault in stringsubst
- Date: Thu, 17 Apr 2014 11:42:52 -0700
- In-reply-to: <20140416044612.GB24565@ewok>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20140416044612.GB24565@ewok>
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