summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-04-29 17:40:15 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-04-29 17:40:15 (GMT)
commit267c1eb9f4c15531f7bf4095ffb56151ad8f9203 (patch)
tree33786fb99afd0004f63f6cd467cf9fe61ee87918 /generic
parentd406bc02245e98984ec2097cea8188fa3f8ded52 (diff)
downloadtcl-267c1eb9f4c15531f7bf4095ffb56151ad8f9203.zip
tcl-267c1eb9f4c15531f7bf4095ffb56151ad8f9203.tar.gz
tcl-267c1eb9f4c15531f7bf4095ffb56151ad8f9203.tar.bz2
Make sure no shared ChannelBuffers get recycled.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclIO.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 08d0d93..6831c47 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -164,6 +164,7 @@ 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 ChannelTimerProc(ClientData clientData);
static int CheckChannelErrors(ChannelState *statePtr,
int direction);
@@ -2239,6 +2240,13 @@ ReleaseChannelBuffer(
}
ckfree((char *) bufPtr);
}
+
+static int
+IsShared(
+ ChannelBuffer *bufPtr)
+{
+ return bufPtr->refCount > 1;
+}
/*
*----------------------------------------------------------------------
@@ -2269,6 +2277,9 @@ RecycleBuffer(
/*
* Do we have to free the buffer to the OS?
*/
+ if (IsShared(bufPtr)) {
+ mustDiscard = 1;
+ }
if (mustDiscard) {
ReleaseChannelBuffer(bufPtr);