summaryrefslogtreecommitdiffstats
path: root/generic/tclTestObj.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclTestObj.c')
-rw-r--r--generic/tclTestObj.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c
index 5627608..f7d2bae 100644
--- a/generic/tclTestObj.c
+++ b/generic/tclTestObj.c
@@ -622,9 +622,23 @@ TestindexobjCmd(
}
argv[objc-4] = NULL;
+ /*
+ * Tcl_GetIndexFromObj assumes that the table is statically-allocated so
+ * that its address is different for each index object. If we accidently
+ * allocate a table at the same address as that cached in the index
+ * object, clear out the object's cached state.
+ */
+
+ if (objv[3]->typePtr != NULL
+ && !strcmp("index", objv[3]->typePtr->name)) {
+ indexRep = objv[3]->internalRep.twoPtrValue.ptr1;
+ if (indexRep->tablePtr == (void *) argv) {
+ TclFreeIntRep(objv[3]);
+ }
+ }
+
result = Tcl_GetIndexFromObj((setError? interp : NULL), objv[3],
- argv, "token", INDEX_TEMP_TABLE|(allowAbbrev? 0 : TCL_EXACT),
- &index);
+ argv, "token", (allowAbbrev? 0 : TCL_EXACT), &index);
ckfree(argv);
if (result == TCL_OK) {
Tcl_SetIntObj(Tcl_GetObjResult(interp), index);
@@ -1101,7 +1115,7 @@ TestobjCmd(
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, Tcl_NewWideIntObj(varPtr[varIndex]->refCount));
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(varPtr[varIndex]->refCount));
} else if (strcmp(subCmd, "type") == 0) {
if (objc != 3) {
goto wrongNumArgs;