diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | generic/tclIO.c | 18 |
2 files changed, 26 insertions, 2 deletions
@@ -1,3 +1,13 @@ +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. + 2001-07-16 Mo DeJong <mdejong@redhat.com> * generic/tcl.h: Define __WIN32__ when 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 { |