summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2010-03-22 22:47:03 (GMT)
committerdgp <dgp@users.sourceforge.net>2010-03-22 22:47:03 (GMT)
commit6838a5c3396760aa126ef99f25c1bb7b992700ba (patch)
treebaaaba081a003c5f560a95e9ae584e28c86bb4ca /generic
parent8e9d12df9d9208d8c13676dfa05cfbb0cf4abf1d (diff)
downloadtcl-6838a5c3396760aa126ef99f25c1bb7b992700ba.zip
tcl-6838a5c3396760aa126ef99f25c1bb7b992700ba.tar.gz
tcl-6838a5c3396760aa126ef99f25c1bb7b992700ba.tar.bz2
* generic/tclCmdMZ.c: [Bug 2973361]: Compute the correct integer
values to identify the argument indices of the various script arguments to [try]. Passing in -1 led to invalid memory reads.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCmdMZ.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 696835a..ebfd7e7 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdMZ.c,v 1.205 2010/03/05 23:12:54 dkf Exp $
+ * RCS: @(#) $Id: tclCmdMZ.c,v 1.206 2010/03/22 22:47:03 dgp Exp $
*/
#include "tclInt.h"
@@ -4351,6 +4351,7 @@ TryPostBody(
{
Tcl_Obj *resultObj, *options, *handlersObj, *finallyObj, *cmdObj;
int i, dummy, code;
+ int numHandlers = 0;
handlersObj = data[0];
finallyObj = data[1];
@@ -4377,7 +4378,7 @@ TryPostBody(
*/
if (handlersObj != NULL) {
- int numHandlers, found = 0;
+ int found = 0;
Tcl_Obj **handlers, **info;
Tcl_ListObjGetElements(NULL, handlersObj, &numHandlers, &handlers);
@@ -4487,7 +4488,7 @@ TryPostBody(
info[0], finallyObj);
Tcl_DecrRefCount(handlersObj);
return TclNREvalObjEx(interp, handlerBodyObj, 0,
- ((Interp *) interp)->cmdFramePtr, -1);
+ ((Interp *) interp)->cmdFramePtr, 4*i + 5);
handlerFailed:
options = During(interp, result, options, NULL);
@@ -4512,7 +4513,7 @@ TryPostBody(
Tcl_NRAddCallback(interp, TryPostFinal, resultObj, INT2PTR(result),
options, cmdObj);
return TclNREvalObjEx(interp, finallyObj, 0,
- ((Interp *) interp)->cmdFramePtr, -1);
+ ((Interp *) interp)->cmdFramePtr, numHandlers*4 + 3);
}
/*
@@ -4574,10 +4575,14 @@ TryPostHandler(
*/
if (finallyObj != NULL) {
+ Interp *iPtr = (Interp *) interp;
+
Tcl_NRAddCallback(interp, TryPostFinal, resultObj, INT2PTR(result),
options, cmdObj);
- return TclNREvalObjEx(interp, finallyObj, 0,
- ((Interp *) interp)->cmdFramePtr, -1);
+
+ /* The 'finally' script is always the last argument word. */
+ return TclNREvalObjEx(interp, finallyObj, 0, iPtr->cmdFramePtr,
+ iPtr->cmdFramePtr->nline - 1);
}
/*