summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs>2001-09-11 00:53:27 (GMT)
committerhobbs <hobbs>2001-09-11 00:53:27 (GMT)
commit1a92eb4faf5782a882d5e0a1da07ec042db62bb4 (patch)
tree06417381e93d446dbb5ddfe0c05ef79693e4345b
parent3d56edaa4ecaed4da35fe78ba68e12bb6803ccac (diff)
downloadtcl-1a92eb4faf5782a882d5e0a1da07ec042db62bb4.zip
tcl-1a92eb4faf5782a882d5e0a1da07ec042db62bb4.tar.gz
tcl-1a92eb4faf5782a882d5e0a1da07ec042db62bb4.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]
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclInterp.c21
-rw-r--r--tests/stack.test10
3 files changed, 32 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 4d78a7b..8f2ed49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-09-10 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * tests/stack.test:
+ * generic/tclInterp.c (AliasObjCmd): Check the numLevels to ensure
+ that we aren't hitting some alias loop condition. [Bug #443184]
+
2001-09-10 Andreas Kupries <andreas_kupries@users.sourceforge.net>
* generic/tclInt.decls: Added 'TclWinFlushDirtyChannels' to
diff --git a/generic/tclInterp.c b/generic/tclInterp.c
index 08b0c31..96c0c7f 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.5.12.1 2001/04/04 14:47:16 dgp Exp $
+ * RCS: @(#) $Id: tclInterp.c,v 1.5.12.2 2001/09/11 00:53:27 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);
diff --git a/tests/stack.test b/tests/stack.test
index 0f57617..07d689b 100644
--- a/tests/stack.test
+++ b/tests/stack.test
@@ -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: stack.test,v 1.8.2.1 2001/04/03 22:54:38 hobbs Exp $
+# RCS: @(#) $Id: stack.test,v 1.8.2.2 2001/09/11 00:53:27 hobbs Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -45,6 +45,14 @@ test stack-1.1 {maxNestingDepth reached on infinite recursion} {minStack2400} {
set rv
} {too many nested calls to Tcl_EvalObj (infinite loop?)}
+test stack-2.1 {maxNestingDepth reached on infinite recursion} {minStack2400} {
+ catch {rename unknown unknown_safe}
+ interp alias {} unknown {} notaknownproc
+ catch {foo} msg
+ catch {rename unknown {} ; rename unknown_safe unknown}
+ set msg
+} {too many nested calls to AliasObjCmd (infinite loop using alias?)}
+
# cleanup
::tcltest::cleanupTests
return