diff options
author | dgp <dgp@users.sourceforge.net> | 2016-03-01 16:45:01 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2016-03-01 16:45:01 (GMT) |
commit | c761f885ddfb0bfdc09e27db3399acb1f1b65dbd (patch) | |
tree | f780a4fc2384f155fb49a9e432d1f54f4d1afe77 /generic/tclVar.c | |
parent | 049650b5952e5e5ee1997772750450305dccc6d7 (diff) | |
parent | 7d6b4ece6967da652c3eeb1f0baced245473353b (diff) | |
download | tcl-c761f885ddfb0bfdc09e27db3399acb1f1b65dbd.zip tcl-c761f885ddfb0bfdc09e27db3399acb1f1b65dbd.tar.gz tcl-c761f885ddfb0bfdc09e27db3399acb1f1b65dbd.tar.bz2 |
[80304238ac] Prevent RC cycle in the localVarName objtype.
Diffstat (limited to 'generic/tclVar.c')
-rw-r--r-- | generic/tclVar.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/generic/tclVar.c b/generic/tclVar.c index 451ef7b..5574f30 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -697,13 +697,16 @@ TclObjLookupVarEx( /* * An indexed local variable. */ + Tcl_Obj *cachedNamePtr = localName(iPtr->varFramePtr, index); part1Ptr->typePtr = &localVarNameType; - if (part1Ptr != localName(iPtr->varFramePtr, index)) { - part1Ptr->internalRep.twoPtrValue.ptr1 = - localName(iPtr->varFramePtr, index); - Tcl_IncrRefCount((Tcl_Obj *) - part1Ptr->internalRep.twoPtrValue.ptr1); + if (part1Ptr != cachedNamePtr) { + part1Ptr->internalRep.twoPtrValue.ptr1 = cachedNamePtr; + Tcl_IncrRefCount(cachedNamePtr); + if (cachedNamePtr->typePtr != &localVarNameType + || cachedNamePtr->internalRep.twoPtrValue.ptr1 != NULL) { + TclFreeIntRep(cachedNamePtr); + } } else { part1Ptr->internalRep.twoPtrValue.ptr1 = NULL; } |