summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorandreas_kupries <akupries@shaw.ca>2001-07-17 17:53:43 (GMT)
committerandreas_kupries <akupries@shaw.ca>2001-07-17 17:53:43 (GMT)
commita79f038e6861042e3ab4d463e61d3ec90d8772b5 (patch)
tree16bf07397d83733414b3a4f47b06e604bf637b57 /generic
parentb8bb94671e8999fad9dd12e9a182bafb1f030c19 (diff)
downloadtcl-a79f038e6861042e3ab4d463e61d3ec90d8772b5.zip
tcl-a79f038e6861042e3ab4d463e61d3ec90d8772b5.tar.gz
tcl-a79f038e6861042e3ab4d463e61d3ec90d8772b5.tar.bz2
2001-07-17 Andreas Kupries <andreas_kupries@users.sourceforge.net>
* generic/tclIO.c (GetInput): Fixed [SF #427196]. Memory was overwritten because a buffer was used after a change of the requested buffersize together with that requested buffersize and not its actual size, which was smaller. Note that the continous reuse of the smaller buffer negatively impacts performance. The system never allocates a buffer with the newly requested bigger buffersize.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclIO.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index f66e96b..fe233ad 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIO.c,v 1.30 2001/05/19 16:59:04 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclIO.c,v 1.31 2001/07/17 17:53:43 andreas_kupries Exp $
*/
#include "tclInt.h"
@@ -4999,7 +4999,21 @@ GetInput(chanPtr)
}
bufPtr->nextPtr = (ChannelBuffer *) NULL;
- toRead = statePtr->bufSize;
+ /* SF #427196: Use the actual size of the buffer to determine
+ * the number of bytes to read from the channel and not the
+ * size for new buffers. They can be different if the
+ * buffersize was changed between reads.
+ *
+ * Note: This affects performance negatively if the buffersize
+ * was extended but this small buffer is reused for all
+ * subsequent reads. The system never uses buffers with the
+ * requested bigger size in that case. An adjunct patch could
+ * try and delete all unused buffers it encounters and which
+ * are smaller than the formally requested buffersize.
+ */
+
+ toRead = bufPtr->bufLength - bufPtr->nextAdded;
+
if (statePtr->inQueueTail == NULL) {
statePtr->inQueueHead = bufPtr;
} else {