--- generic/threadSvCmd.c +++ generic/threadSvCmd.c @@ -1316,11 +1316,13 @@ * storage and cache all key/value pairs found there into tne * newly created shared array. */ PsStore *psPtr; + Tcl_HashEntry *hPtr; size_t len; + int new; char *psurl, *key = NULL, *val = NULL; if (objc < 4) { Tcl_WrongNumArgs(interp, 2, objv, "array handle"); ret = TCL_ERROR; @@ -1343,11 +1345,11 @@ ret = TCL_ERROR; goto cmdExit; } if (arrayPtr) { Tcl_HashSearch search; - Tcl_HashEntry *hPtr = Tcl_FirstHashEntry(&arrayPtr->vars,&search); + hPtr = Tcl_FirstHashEntry(&arrayPtr->vars,&search); arrayPtr->psPtr = psPtr; arrayPtr->bindAddr = strcpy(ckalloc(len+1), psurl); while (hPtr) { svObj = Tcl_GetHashValue(hPtr); if (ReleaseContainer(interp, svObj, SV_CHANGED) != TCL_OK) { @@ -1361,12 +1363,14 @@ arrayPtr->psPtr = psPtr; arrayPtr->bindAddr = strcpy(ckalloc(len+1), psurl); } if (!psPtr->psFirst(psPtr->psHandle, &key, &val, &len)) { do { - psPtr->psFree(val); /* What a waste! */ - AcquireContainer(arrayPtr, key, FLAGS_CREATEVAR); + Tcl_Obj * tclObj = Tcl_NewStringObj(val, len); + hPtr = Tcl_CreateHashEntry(&arrayPtr->vars, key, &new); + Tcl_SetHashValue(hPtr, CreateContainer(arrayPtr, hPtr, tclObj)); + psPtr->psFree(val); } while (!psPtr->psNext(psPtr->psHandle, &key, &val, &len)); } } else if (index == AUNBIND) { if (arrayPtr && arrayPtr->psPtr) {