summaryrefslogtreecommitdiffstats
path: root/generic/tclLiteral.c
diff options
context:
space:
mode:
authorstanton <stanton@noemail.net>1999-04-28 01:56:39 (GMT)
committerstanton <stanton@noemail.net>1999-04-28 01:56:39 (GMT)
commit5242f536b4b21d0d0f7990b7853cc2739d4355fa (patch)
tree5a6ad39a22e57a87179bc1df5782626ef72ebcad /generic/tclLiteral.c
parent1518fbfc2f6d7a8c0f54b48c3625a77e2e0f41e5 (diff)
downloadtcl-5242f536b4b21d0d0f7990b7853cc2739d4355fa.zip
tcl-5242f536b4b21d0d0f7990b7853cc2739d4355fa.tar.gz
tcl-5242f536b4b21d0d0f7990b7853cc2739d4355fa.tar.bz2
* generic/tclLiteral.c (TclHideLiteral): Fixed so hidden literals
get duplicated to avoid accidental sharing in the global object table. FossilOrigin-Name: 4c22f31e66a2eb1ebce22968336b60e50bc4d3c0
Diffstat (limited to 'generic/tclLiteral.c')
-rw-r--r--generic/tclLiteral.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c
index 1141155..f180d11 100644
--- a/generic/tclLiteral.c
+++ b/generic/tclLiteral.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclLiteral.c,v 1.3 1999/04/22 22:57:07 stanton Exp $
+ * RCS: @(#) $Id: tclLiteral.c,v 1.4 1999/04/28 01:56:39 stanton Exp $
*/
#include "tclInt.h"
@@ -407,19 +407,23 @@ TclHideLiteral(interp, envPtr, index)
LiteralTable *localTablePtr = &(envPtr->localLitTable);
int localHash, length;
char *bytes;
+ Tcl_Obj *newObjPtr;
lPtr = &(envPtr->literalArrayPtr[index]);
/*
- * We need to bump the object refcount to avoid having the object freed
- * when we remove the last global reference.
+ * To avoid unwanted sharing we need to copy the object and remove it from
+ * the local and global literal tables. It still has a slot in the literal
+ * array so it can be referred to by byte codes, but it will not be matched
+ * by literal searches.
*/
- Tcl_IncrRefCount(lPtr->objPtr);
-
+ newObjPtr = Tcl_DuplicateObj(lPtr->objPtr);
+ Tcl_IncrRefCount(newObjPtr);
TclReleaseLiteral(interp, lPtr->objPtr);
+ lPtr->objPtr = newObjPtr;
- bytes = Tcl_GetStringFromObj(lPtr->objPtr, &length);
+ bytes = Tcl_GetStringFromObj(newObjPtr, &length);
localHash = (HashString(bytes, length) & localTablePtr->mask);
nextPtrPtr = &localTablePtr->buckets[localHash];