diff options
author | dgp <dgp@users.sourceforge.net> | 2015-02-05 19:23:35 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2015-02-05 19:23:35 (GMT) |
commit | df3478c0c508d7065be2d48ab3b48f405dd80b18 (patch) | |
tree | 66baeff276e3d0219470089659d3c7b051fa0b38 | |
parent | 9f39fc4286082e4e7a7b52711f7b37c8c6fddf7c (diff) | |
download | tcl-df3478c0c508d7065be2d48ab3b48f405dd80b18.zip tcl-df3478c0c508d7065be2d48ab3b48f405dd80b18.tar.gz tcl-df3478c0c508d7065be2d48ab3b48f405dd80b18.tar.bz2 |
Backport of channel mem leak fix that got missed before.
-rw-r--r-- | generic/tclIO.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index b3af1f5..5a25243 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -166,6 +166,7 @@ static ChannelBuffer * AllocChannelBuffer(int length); static void PreserveChannelBuffer(ChannelBuffer *bufPtr); static void ReleaseChannelBuffer(ChannelBuffer *bufPtr); static int IsShared(ChannelBuffer *bufPtr); +static void ChannelFree(Channel *chanPtr); static void ChannelTimerProc(ClientData clientData); static int ChanRead(Channel *chanPtr, char *dst, int dstSize); static int CheckChannelErrors(ChannelState *statePtr, @@ -1819,6 +1820,16 @@ TclChannelRelease( } } +static void +ChannelFree( + Channel *chanPtr) +{ + if (chanPtr->refCount == 0) { + ckfree((char *)chanPtr); + return; + } + chanPtr->typePtr = NULL; +} /* *---------------------------------------------------------------------- @@ -1977,7 +1988,7 @@ Tcl_UnstackChannel( interp, 0); } - chanPtr->typePtr = NULL; + ChannelFree(chanPtr); UpdateInterest(statePtr->topChanPtr); @@ -2916,7 +2927,8 @@ CloseChannel( statePtr->topChanPtr = downChanPtr; downChanPtr->upChanPtr = NULL; - chanPtr->typePtr = NULL; + + ChannelFree(chanPtr); return Tcl_Close(interp, (Tcl_Channel) downChanPtr); } @@ -2927,7 +2939,7 @@ CloseChannel( * stack, make sure to free the ChannelState structure associated with it. */ - chanPtr->typePtr = NULL; + ChannelFree(chanPtr); Tcl_EventuallyFree(statePtr, TCL_DYNAMIC); |