1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-06-24 23:38:04 +02:00

Fix function stack unwinding on autoload failures.

This commit is contained in:
Bart Schaefer 2001-07-09 16:20:53 +00:00
parent 003ec8c7e8
commit 7457bdc19d
2 changed files with 12 additions and 6 deletions

View file

@ -6,6 +6,11 @@
do this sometimes in order for existing $LINENO to show through. do this sometimes in order for existing $LINENO to show through.
This seems to cause more problems than it solves. This seems to cause more problems than it solves.
2001-07-09 Bart Schaefer <schaefer@zsh.org>
* 15321: Src/exec.c: Fix line numbers in an error message; unwind
function context properly on obscure autoloading failures.
2001-07-07 Bart Schaefer <schaefer@zsh.org> 2001-07-07 Bart Schaefer <schaefer@zsh.org>
* 15308: Src/builtin.c: Fix infinite loop on `r OLD=NEW' when OLD * 15308: Src/builtin.c: Fix infinite loop on `r OLD=NEW' when OLD

View file

@ -3273,7 +3273,10 @@ loadautofn(Shfunc shf, int fksh, int autol)
execode(prog, 1, 0); execode(prog, 1, 0);
shf = (Shfunc) shfunctab->getnode(shfunctab, n); shf = (Shfunc) shfunctab->getnode(shfunctab, n);
if (!shf || (shf->flags & PM_UNDEFINED)) { if (!shf || (shf->flags & PM_UNDEFINED)) {
/* We're not actually in the function; decrement locallevel */
locallevel--;
zwarn("%s: function not defined by file", n, 0); zwarn("%s: function not defined by file", n, 0);
locallevel++;
popheap(); popheap();
return NULL; return NULL;
} }
@ -3359,9 +3362,7 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval)
if(++funcdepth > MAX_FUNCTION_DEPTH) if(++funcdepth > MAX_FUNCTION_DEPTH)
{ {
zerr("maximum nested function level reached", NULL, 0); zerr("maximum nested function level reached", NULL, 0);
scriptname = oldscriptname; goto undoshfunc;
popheap();
return;
} }
#endif #endif
fstack.name = dupstring(name); fstack.name = dupstring(name);
@ -3382,15 +3383,15 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval)
errflag = 1; errflag = 1;
else else
lastval = 1; lastval = 1;
popheap(); goto doneshfunc;
scriptname = oldscriptname;
return;
} }
prog = shf->funcdef; prog = shf->funcdef;
} }
runshfunc(prog, wrappers, fstack.name); runshfunc(prog, wrappers, fstack.name);
doneshfunc:
funcstack = fstack.prev; funcstack = fstack.prev;
#ifdef MAX_FUNCTION_DEPTH #ifdef MAX_FUNCTION_DEPTH
undoshfunc:
--funcdepth; --funcdepth;
#endif #endif
if (retflag) { if (retflag) {