summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2007-03-01 10:16:09 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2007-03-01 10:16:09 (GMT)
commitbbd1a40279d2d032cb29ed36ce0ed0e6105f16c8 (patch)
tree3a2cdb549c109b3cc5f7794e2dcfb3988d7f35da /generic
parent26963260767dbf3573cc0b7a260372a5bac01be8 (diff)
downloadtcl-bbd1a40279d2d032cb29ed36ce0ed0e6105f16c8.zip
tcl-bbd1a40279d2d032cb29ed36ce0ed0e6105f16c8.tar.gz
tcl-bbd1a40279d2d032cb29ed36ce0ed0e6105f16c8.tar.bz2
Fix [Bug 1671138]
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCompCmds.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 0737ab2..9c20bac 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompCmds.c,v 1.39.2.4 2006/11/28 22:20:00 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclCompCmds.c,v 1.39.2.5 2007/03/01 10:16:10 dkf Exp $
*/
#include "tclInt.h"
@@ -894,6 +894,18 @@ TclCompileForeachCmd(interp, parsePtr, envPtr)
goto done;
}
numVars = varcList[loopIndex];
+
+ /*
+ * If the variable list is empty, we can enter an infinite
+ * loop when the interpreted version would not. Take care to
+ * ensure this does not happen. [Bug 1671138]
+ */
+
+ if (numVars == 0) {
+ code = TCL_ERROR;
+ goto done;
+ }
+
for (j = 0; j < numVars; j++) {
CONST char *varName = varvList[loopIndex][j];
if (!TclIsLocalScalar(varName, (int) strlen(varName))) {