summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2007-09-03 21:27:21 (GMT)
committerKevin B Kenny <kennykb@acm.org>2007-09-03 21:27:21 (GMT)
commit3dcd08753c27584928c9a436994a06388befdd76 (patch)
tree237dbf3798cc08dc20e1d810f79420fabfdf3a59 /generic
parent888220f579233ef922204f8d235b9cf5693682c5 (diff)
downloadtcl-3dcd08753c27584928c9a436994a06388befdd76.zip
tcl-3dcd08753c27584928c9a436994a06388befdd76.tar.gz
tcl-3dcd08753c27584928c9a436994a06388befdd76.tar.bz2
* tests/lindex.test (lindex-17.[01]): Added code to detect the
error when a script does [lindex {} end foo]; an overaggressive optimisation caused this call to return an empty object rather than an error.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclListObj.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 170831f..c1d1bfa 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclListObj.c,v 1.46 2007/04/24 22:31:39 msofer Exp $
+ * RCS: @(#) $Id: tclListObj.c,v 1.47 2007/09/03 21:27:22 kennykb Exp $
*/
#include "tclInt.h"
@@ -1108,10 +1108,17 @@ TclLindexFlat(
if (index<0 || index>=listLen) {
/*
* Index is out of range. Break out of loop with empty result.
+ * First check remaining indices for validity
*/
+ while (++i < indexCount) {
+ if (TclGetIntForIndex(interp, indexArray[i], -1, &index)
+ != TCL_OK) {
+ Tcl_DecrRefCount(sublistCopy);
+ return NULL;
+ }
+ }
listPtr = Tcl_NewObj();
- i = indexCount;
} else {
/*
* Extract the pointer to the appropriate element.