summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorhobbs <hobbs>2001-09-11 00:46:35 (GMT)
committerhobbs <hobbs>2001-09-11 00:46:35 (GMT)
commit2d6d1c0b8b709857509a6107d227c5d3764a0104 (patch)
tree2a977aab7fbca2d585722bad30add8c92ec05768 /generic
parent6448477ebf489632da32e76dd33d6f42735d390f (diff)
downloadtcl-2d6d1c0b8b709857509a6107d227c5d3764a0104.zip
tcl-2d6d1c0b8b709857509a6107d227c5d3764a0104.tar.gz
tcl-2d6d1c0b8b709857509a6107d227c5d3764a0104.tar.bz2
* tests/stack.test:
* generic/tclInterp.c (AliasObjCmd): Check the numLevels to ensure that we aren't hitting some alias loop condition. [Bug #443184]
Diffstat (limited to 'generic')
-rw-r--r--generic/tclInterp.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/generic/tclInterp.c b/generic/tclInterp.c
index 106bf50..fcc27bd 100644
--- a/generic/tclInterp.c
+++ b/generic/tclInterp.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclInterp.c,v 1.6 2001/04/04 07:11:01 dgp Exp $
+ * RCS: @(#) $Id: tclInterp.c,v 1.7 2001/09/11 00:46:35 hobbs Exp $
*/
#include <stdio.h>
@@ -1398,6 +1398,19 @@ AliasObjCmd(clientData, interp, objc, objv)
Tcl_AllowExceptions(targetInterp);
/*
+ * Check depth of nested calls with AliasObjCmd: if this gets too large,
+ * it's probably because of an infinite loop somewhere.
+ */
+
+ if (((Interp *) targetInterp)->numLevels >
+ ((Interp *) targetInterp)->maxNestingDepth) {
+ Tcl_AppendToObj(Tcl_GetObjResult(targetInterp),
+ "too many nested calls to AliasObjCmd (infinite loop using alias?)", -1);
+ result = TCL_ERROR;
+ goto done;
+ }
+
+ /*
* Append the arguments to the command prefix and invoke the command
* in the target interp's global namespace.
*/
@@ -1410,8 +1423,6 @@ AliasObjCmd(clientData, interp, objc, objv)
TCL_INVOKE_NO_TRACEBACK);
Tcl_DecrRefCount(cmdPtr);
- ((Interp *) targetInterp)->numLevels--;
-
/*
* Check if we are at the bottom of the stack for the target interpreter.
* If so, check for special return codes.
@@ -1441,7 +1452,9 @@ AliasObjCmd(clientData, interp, objc, objv)
result = TCL_ERROR;
}
}
-
+ done:
+ ((Interp *) targetInterp)->numLevels--;
+
TclTransferResult(targetInterp, result, interp);
Tcl_Release((ClientData) targetInterp);