diff options
author | sebres <sebres@users.sourceforge.net> | 2024-05-17 12:57:46 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2024-05-17 12:57:46 (GMT) |
commit | 46770d4bb18fad9cacfcd3bf16ad95a5280b1ca4 (patch) | |
tree | c64acb23db56140905c09335807ec11efbf8be48 /generic | |
parent | 4fb3e71bda90cd40070e96dc5cbf200ed957cc41 (diff) | |
parent | 0c8986dc65b0034df10a77db626ef663285574a3 (diff) | |
download | tcl-46770d4bb18fad9cacfcd3bf16ad95a5280b1ca4.zip tcl-46770d4bb18fad9cacfcd3bf16ad95a5280b1ca4.tar.gz tcl-46770d4bb18fad9cacfcd3bf16ad95a5280b1ca4.tar.bz2 |
merge apn-channelstate-leak, fixes possible leaks on several members that may be set after the close, asynchronously or via some callbacks or handlers
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclIO.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index c3844af..165a07e 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -2949,6 +2949,34 @@ FlushChannel( return errorCode; } +static void +FreeChannelState( + char *blockPtr) /* Channel state to free. */ +{ + ChannelState *statePtr = (ChannelState *)blockPtr; + /* + * Even after close some members can be filled again (in events etc). + * Test in bug [79474c588] illustrates one leak (on remaining chanMsg). + * Possible other fields need freeing on some constellations. + */ + + DiscardInputQueued(statePtr, 1); + if (statePtr->curOutPtr != NULL) { + ReleaseChannelBuffer(statePtr->curOutPtr); + } + DiscardOutputQueued(statePtr); + + DeleteTimerHandler(statePtr); + + if (statePtr->chanMsg) { + Tcl_DecrRefCount(statePtr->chanMsg); + } + if (statePtr->unreportedMsg) { + Tcl_DecrRefCount(statePtr->unreportedMsg); + } + ckfree(statePtr); +} + /* *---------------------------------------------------------------------- * @@ -3125,7 +3153,7 @@ CloseChannel( ChannelFree(chanPtr); - Tcl_EventuallyFree(statePtr, TCL_DYNAMIC); + Tcl_EventuallyFree(statePtr, FreeChannelState); return errorCode; } |