summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2010-03-24 10:25:59 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2010-03-24 10:25:59 (GMT)
commit26683d2945cd970b898e6e20c238bdc844c9af94 (patch)
treede9ed51a102ca279a12fa3ba0b5effcc98e9d5e4 /generic
parentca6cb5920260f029a64602994d097845239aacd3 (diff)
downloadtcl-26683d2945cd970b898e6e20c238bdc844c9af94.zip
tcl-26683d2945cd970b898e6e20c238bdc844c9af94.tar.gz
tcl-26683d2945cd970b898e6e20c238bdc844c9af94.tar.bz2
* generic/tclCmdMZ.c (TryPostBody, TryPostHandler): Make sure that the
[try] command does not trap unwinding due to limits.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCmdMZ.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 6c311f9b..e63e07c 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -10,12 +10,12 @@
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
* Copyright (c) 1998-2000 Scriptics Corporation.
* Copyright (c) 2002 ActiveState Corporation.
- * Copyright (c) 2003 Donal K. Fellows.
+ * Copyright (c) 2003-2009 Donal K. Fellows.
*
* 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.208 2010/03/23 23:25:55 dgp Exp $
+ * RCS: @(#) $Id: tclCmdMZ.c,v 1.209 2010/03/24 10:25:59 dkf Exp $
*/
#include "tclInt.h"
@@ -4363,17 +4363,31 @@ TryPostBody(
cmdObj = objv[0];
/*
+ * Check for limits/rewinding, which override normal trapping behaviour.
+ */
+
+ if (((Interp*) interp)->execEnvPtr->rewind || Tcl_LimitExceeded(interp)) {
+ Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
+ "\n (\"%s\" body line %d)", TclGetString(cmdObj),
+ Tcl_GetErrorLine(interp)));
+ if (handlersObj != NULL) {
+ Tcl_DecrRefCount(handlersObj);
+ }
+ return TCL_ERROR;
+ }
+
+ /*
* Basic processing of the outcome of the script, including adding of
* errorinfo trace.
*/
- resultObj = Tcl_GetObjResult(interp);
- Tcl_IncrRefCount(resultObj);
if (result == TCL_ERROR) {
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
"\n (\"%s\" body line %d)", TclGetString(cmdObj),
Tcl_GetErrorLine(interp)));
}
+ resultObj = Tcl_GetObjResult(interp);
+ Tcl_IncrRefCount(resultObj);
options = Tcl_GetReturnOptions(interp, result);
Tcl_IncrRefCount(options);
Tcl_ResetResult(interp);
@@ -4554,7 +4568,6 @@ TryPostHandler(
Tcl_Obj *finallyObj;
int finally;
-
objv = data[0];
options = data[1];
handlerKindObj = data[2];
@@ -4564,6 +4577,19 @@ TryPostHandler(
finallyObj = finally ? objv[finally] : 0;
/*
+ * Check for limits/rewinding, which override normal trapping behaviour.
+ */
+
+ if (((Interp*) interp)->execEnvPtr->rewind || Tcl_LimitExceeded(interp)) {
+ options = During(interp, result, options, Tcl_ObjPrintf(
+ "\n (\"%s ... %s\" handler line %d)",
+ TclGetString(cmdObj), TclGetString(handlerKindObj),
+ Tcl_GetErrorLine(interp)));
+ Tcl_DecrRefCount(options);
+ return TCL_ERROR;
+ }
+
+ /*
* The handler result completely substitutes for the result of the body.
*/