summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2015-02-05 19:23:35 (GMT)
committerdgp <dgp@users.sourceforge.net>2015-02-05 19:23:35 (GMT)
commitdf3478c0c508d7065be2d48ab3b48f405dd80b18 (patch)
tree66baeff276e3d0219470089659d3c7b051fa0b38 /generic
parent9f39fc4286082e4e7a7b52711f7b37c8c6fddf7c (diff)
downloadtcl-df3478c0c508d7065be2d48ab3b48f405dd80b18.zip
tcl-df3478c0c508d7065be2d48ab3b48f405dd80b18.tar.gz
tcl-df3478c0c508d7065be2d48ab3b48f405dd80b18.tar.bz2
Backport of channel mem leak fix that got missed before.
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 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);