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)
commit620cf6fa02dbbb41fb375bcad80ec0b5851462b4 (patch)
tree283bcf194741cc1447a901c90dd1fd35d42b1d6d /generic
parenteb64ed3cf0f46df62592a5b842c87deec3e8b399 (diff)
downloadtcl-620cf6fa02dbbb41fb375bcad80ec0b5851462b4.zip
tcl-620cf6fa02dbbb41fb375bcad80ec0b5851462b4.tar.gz
tcl-620cf6fa02dbbb41fb375bcad80ec0b5851462b4.tar.bz2
Likely fix for channel mem leaks.
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);