summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authorandreas_kupries <andreas_kupries@noemail.net>2001-07-17 17:53:42 (GMT)
committerandreas_kupries <andreas_kupries@noemail.net>2001-07-17 17:53:42 (GMT)
commit783d87574897c96f852a7e0a39b5be9dd38a33b4 (patch)
tree16bf07397d83733414b3a4f47b06e604bf637b57 /generic/tclIO.c
parentb97633aff87d51060583cbb483988a2386b7eb6b (diff)
downloadtcl-783d87574897c96f852a7e0a39b5be9dd38a33b4.zip
tcl-783d87574897c96f852a7e0a39b5be9dd38a33b4.tar.gz
tcl-783d87574897c96f852a7e0a39b5be9dd38a33b4.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. FossilOrigin-Name: c3fafed4c209104cc9d4f50e66c13b941e7005dc
Diffstat (limited to 'generic/tclIO.c')
-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 {