From 127788364951212c356aadc39deb21e01b0161c8 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Thu, 27 May 2010 11:32:55 +0800 Subject: [VAR] Fix poplocalvar on abnormal exit from function The new localvar code broke the abnormal exit from functions and built-ins by not restoring the original localvar state. This patch fixes this by storing the previous localvar state so that we always unwind correctly in case of an abnormal exit. Signed-off-by: Herbert Xu --- src/eval.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/eval.c') diff --git a/src/eval.c b/src/eval.c index a6981a9..2cd931b 100644 --- a/src/eval.c +++ b/src/eval.c @@ -681,6 +681,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd) evalcommand(union node *cmd, int flags) #endif { + struct localvar_list *localvar_stop; struct stackmark smark; union node *argp; struct arglist arglist; @@ -703,7 +704,7 @@ evalcommand(union node *cmd, int flags) /* First expand the arguments. */ TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags)); setstackmark(&smark); - pushlocalvars(); + localvar_stop = pushlocalvars(); back_exitstatus = 0; cmdentry.cmdtype = CMDBUILTIN; @@ -837,7 +838,6 @@ bail: if (forkshell(jp, cmd, FORK_FG) != 0) { exitstatus = waitforjob(jp); INTON; - poplocalvars(0); break; } FORCEINTON; @@ -878,6 +878,7 @@ raise: out: popredir(execcmd); + unwindlocalvars(localvar_stop); if (lastarg) /* dsl: I think this is intended to be used to support * '_' in 'vi' command mode during line editing... -- cgit 1.4.1