summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 2df8696..adcf513 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -157,7 +157,8 @@ typedef struct CloseCallback {
static ChannelBuffer * AllocChannelBuffer(int length);
static void PreserveChannelBuffer(ChannelBuffer *bufPtr);
static void ReleaseChannelBuffer(ChannelBuffer *bufPtr);
-static int IsShared(ChannelBuffer *bufPtr);
+static void FreeChannelState(char *blockPtr);
+static int IsShared(ChannelBuffer *bufPtr);
static void ChannelFree(Channel *chanPtr);
static void ChannelTimerProc(void *clientData);
static int ChanRead(Channel *chanPtr, char *dst, int dstSize);
@@ -2949,6 +2950,23 @@ FlushChannel(
return errorCode;
}
+static void FreeChannelState(char *blockPtr)
+{
+ ChannelState *statePtr = (ChannelState *)blockPtr;
+ /*
+ * Bug [79474c588] leak. Possible other fields need freeing but
+ * not clear if they are already freed and if the fields are set to NULL
+ * when they are. Test suite shows no other leaks at the moment.
+ */
+ if (statePtr->chanMsg) {
+ Tcl_DecrRefCount(statePtr->chanMsg);
+ }
+ if (statePtr->unreportedMsg) {
+ Tcl_DecrRefCount(statePtr->unreportedMsg);
+ }
+ ckfree(statePtr);
+}
+
/*
*----------------------------------------------------------------------
*
@@ -3125,7 +3143,7 @@ CloseChannel(
ChannelFree(chanPtr);
- Tcl_EventuallyFree(statePtr, TCL_DYNAMIC);
+ Tcl_EventuallyFree(statePtr, FreeChannelState);
return errorCode;
}