summaryrefslogtreecommitdiffstats
path: root/generic/tclIndexObj.c
diff options
context:
space:
mode:
authorredman <redman@noemail.net>1999-06-28 23:49:29 (GMT)
committerredman <redman@noemail.net>1999-06-28 23:49:29 (GMT)
commit64cc0908e2b42c4fc474166207e724f82598cfab (patch)
tree97d30bfa6cb6e1eb503e59a1639c8fccd6e6d486 /generic/tclIndexObj.c
parenta559cfc3f337922e167d797f1d4ba0117178f0d5 (diff)
downloadtcl-64cc0908e2b42c4fc474166207e724f82598cfab.zip
tcl-64cc0908e2b42c4fc474166207e724f82598cfab.tar.gz
tcl-64cc0908e2b42c4fc474166207e724f82598cfab.tar.bz2
Applied patch from Peter Hardie (with modifications) to fix
Tcl_GetIndexFromObj when the key is "". Added test cases and doc note. FossilOrigin-Name: 4fe945f8856dd33e3452d3873bdb9dcefb3ec8dd
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++) {