summaryrefslogtreecommitdiffstats
path: root/generic/tclIndexObj.c
diff options
context:
space:
mode:
authorredman <redman>1999-06-28 23:49:29 (GMT)
committerredman <redman>1999-06-28 23:49:29 (GMT)
commit71008cf5a42b9cda92ef5051322cb11dee863e91 (patch)
tree97d30bfa6cb6e1eb503e59a1639c8fccd6e6d486 /generic/tclIndexObj.c
parentc258b333c62e72fc2f07289988d0989a8742f6df (diff)
downloadtcl-71008cf5a42b9cda92ef5051322cb11dee863e91.zip
tcl-71008cf5a42b9cda92ef5051322cb11dee863e91.tar.gz
tcl-71008cf5a42b9cda92ef5051322cb11dee863e91.tar.bz2
Applied patch from Peter Hardie (with modifications) to fix
Tcl_GetIndexFromObj when the key is "". Added test cases and doc note.
Diffstat (limited to 'generic/tclIndexObj.c')
-rw-r--r--generic/tclIndexObj.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c
index 5acb6c5..eedb259 100644
--- a/generic/tclIndexObj.c
+++ b/generic/tclIndexObj.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: tclIndexObj.c,v 1.3 1999/04/16 00:46:47 stanton Exp $
+ * RCS: @(#) $Id: tclIndexObj.c,v 1.4 1999/06/28 23:49:31 redman Exp $
*/
#include "tclInt.h"
@@ -173,6 +173,15 @@ Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags,
key = Tcl_GetStringFromObj(objPtr, &length);
index = -1;
numAbbrev = 0;
+
+ /*
+ * The key should not be empty, otherwise it's not a match.
+ */
+
+ if (key[0] == '\0') {
+ goto error;
+ }
+
for (entryPtr = tablePtr, i = 0; *entryPtr != NULL;
entryPtr = (char **) ((long) entryPtr + offset), i++) {
for (p1 = key, p2 = *entryPtr; *p1 == *p2; p1++, p2++) {