summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-11-11 22:23:57 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-11-11 22:23:57 (GMT)
commitd18e6da3e471bdaecc24da3e4dfb28620b880daa (patch)
tree283bcf194741cc1447a901c90dd1fd35d42b1d6d /generic
parent3e48a2fd72b0b60f4e8f3d59eccd73a3c39d8d9d (diff)
downloadtcl-d18e6da3e471bdaecc24da3e4dfb28620b880daa.zip
tcl-d18e6da3e471bdaecc24da3e4dfb28620b880daa.tar.gz
tcl-d18e6da3e471bdaecc24da3e4dfb28620b880daa.tar.bz2
Likely fix for channel mem leaks.core_8_6_3core_8_6_3_rc
Diffstat (limited to 'generic')
-rw-r--r--generic/tclIO.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 8ec2a1e..2025742 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -155,6 +155,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,
@@ -1914,6 +1915,16 @@ TclChannelRelease(
}
}
+static void
+ChannelFree(
+ Channel *chanPtr)
+{
+ if (chanPtr->refCount == 0) {
+ ckfree(chanPtr);
+ return;
+ }
+ chanPtr->typePtr = NULL;
+}
/*
*----------------------------------------------------------------------
@@ -2060,7 +2071,7 @@ Tcl_UnstackChannel(
*/
result = ChanClose(chanPtr, interp);
- chanPtr->typePtr = NULL;
+ ChannelFree(chanPtr);
UpdateInterest(statePtr->topChanPtr);
@@ -3018,7 +3029,8 @@ CloseChannel(
statePtr->topChanPtr = downChanPtr;
downChanPtr->upChanPtr = NULL;
- chanPtr->typePtr = NULL;
+
+ ChannelFree(chanPtr);
return Tcl_Close(interp, (Tcl_Channel) downChanPtr);
}
@@ -3029,7 +3041,7 @@ CloseChannel(
* stack, make sure to free the ChannelState structure associated with it.
*/
- chanPtr->typePtr = NULL;
+ ChannelFree(chanPtr);
Tcl_EventuallyFree(statePtr, TCL_DYNAMIC);