summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
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)
commit2fabe1cead1b5b6dd2fa65191162d9d7f41d8881 (patch)
tree66baeff276e3d0219470089659d3c7b051fa0b38 /generic/tclIO.c
parent8ee4bdf94d73b352621e92007ed58ed72389adc7 (diff)
downloadtcl-2fabe1cead1b5b6dd2fa65191162d9d7f41d8881.zip
tcl-2fabe1cead1b5b6dd2fa65191162d9d7f41d8881.tar.gz
tcl-2fabe1cead1b5b6dd2fa65191162d9d7f41d8881.tar.bz2
Backport of channel mem leak fix that got missed before.
Diffstat (limited to 'generic/tclIO.c')
-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);