diff options
author | dgp <dgp@users.sourceforge.net> | 2016-02-26 15:42:33 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2016-02-26 15:42:33 (GMT) |
commit | e31370213070e90006eb4aae378d73945eec6d51 (patch) | |
tree | 35ac483eb72185d6e9e93c9be5b8505682b62540 /generic | |
parent | 96f8fc81311574307013ca7a6f4abc589600d848 (diff) | |
download | tcl-e31370213070e90006eb4aae378d73945eec6d51.zip tcl-e31370213070e90006eb4aae378d73945eec6d51.tar.gz tcl-e31370213070e90006eb4aae378d73945eec6d51.tar.bz2 |
[80304238ac] Candidate fix for memleak due to RC cycle.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclVar.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/generic/tclVar.c b/generic/tclVar.c index 451ef7b..12e52c2 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -697,13 +697,15 @@ 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) { + TclFreeIntRep(cachedNamePtr); + } } else { part1Ptr->internalRep.twoPtrValue.ptr1 = NULL; } |