summaryrefslogtreecommitdiffstats
path: root/generic/tclCompCmds.c
diff options
context:
space:
mode:
authormig <mig>2013-12-22 12:52:39 (GMT)
committermig <mig>2013-12-22 12:52:39 (GMT)
commitdb9c1d285e21754818474eaa9be0d31b7c05e7d5 (patch)
tree91b963a2fafa28525ecd9c8fadddbb5eda37da5d /generic/tclCompCmds.c
parentdb7ebfac4369ff2b956e1f5d7a8865e88d4ffc50 (diff)
downloadtcl-db9c1d285e21754818474eaa9be0d31b7c05e7d5.zip
tcl-db9c1d285e21754818474eaa9be0d31b7c05e7d5.tar.gz
tcl-db9c1d285e21754818474eaa9be0d31b7c05e7d5.tar.bz2
fix stack counting bug in new catch compiler, commit 62a51cdb45.
Diffstat (limited to 'generic/tclCompCmds.c')
-rw-r--r--generic/tclCompCmds.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index b7fc9b5..94d3a69 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -533,7 +533,7 @@ TclCompileCatchCmd(
{
JumpFixup jumpFixup;
Tcl_Token *cmdTokenPtr, *resultNameTokenPtr, *optsNameTokenPtr;
- int resultIndex, optsIndex, range;
+ int resultIndex, optsIndex, range, dropScript = 0;
DefineLineInformation; /* TIP #280 */
/*
@@ -601,6 +601,7 @@ TclCompileCatchCmd(
ExceptionRangeStarts(envPtr, range);
BODY(cmdTokenPtr, 1);
} else {
+ dropScript = 1;
SetLineInformation(1);
CompileTokens(envPtr, cmdTokenPtr, interp);
TclEmitInstInt4( INST_BEGIN_CATCH4, range, envPtr);
@@ -608,6 +609,7 @@ TclCompileCatchCmd(
TclEmitOpcode( INST_DUP, envPtr);
TclEmitInvoke(envPtr, INST_EVAL_STK);
/* drop the script */
+ dropScript = 1;
TclEmitInstInt4( INST_REVERSE, 2, envPtr);
TclEmitOpcode( INST_POP, envPtr);
}
@@ -626,8 +628,12 @@ TclCompileCatchCmd(
* return code.
*/
- TclAdjustStackDepth(-2, envPtr);
+ TclAdjustStackDepth(-2 + dropScript, envPtr);
ExceptionRangeTarget(envPtr, range, catchOffset);
+ if (dropScript) {
+ TclEmitOpcode( INST_POP, envPtr);
+ }
+
/* Stack at this point is empty */
TclEmitOpcode( INST_PUSH_RESULT, envPtr);
TclEmitOpcode( INST_PUSH_RETURN_CODE, envPtr);