diff options
author | andreas_kupries <andreas_kupries@noemail.net> | 2009-11-12 17:03:01 (GMT) |
---|---|---|
committer | andreas_kupries <andreas_kupries@noemail.net> | 2009-11-12 17:03:01 (GMT) |
commit | ed9e06bca877856d0a2d186b61ecd97984785a86 (patch) | |
tree | 10ebf78bfca1a1313bf0a7761dcd34b855cab375 /generic/tclIO.c | |
parent | 4600b589ea85b51bca6fccb17b29da35410504e2 (diff) | |
download | tcl-ed9e06bca877856d0a2d186b61ecd97984785a86.zip tcl-ed9e06bca877856d0a2d186b61ecd97984785a86.tar.gz tcl-ed9e06bca877856d0a2d186b61ecd97984785a86.tar.bz2 |
* generic/tclIO.c (CopyData): [Bug 2895565]. Dropped bogosity
which used the number of _written_ bytes or character to update
the counters for the read bytes/characters. See last entry for the
test case.
FossilOrigin-Name: baab8a7a175664062ebdeab8f7d0a1104616fdf0
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r-- | generic/tclIO.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 2b57079..b072cbf 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.137.2.14 2009/11/11 00:04:27 ferrieux Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.137.2.15 2009/11/12 17:03:02 andreas_kupries Exp $ */ #include "tclInt.h" @@ -8726,14 +8726,17 @@ CopyData( sizeb = DoWriteChars(outStatePtr->topChanPtr, buffer, sizeb); } - if (inBinary || sameEncoding) { - /* - * Both read and write counted bytes. - */ - - size = sizeb; - } /* else: Read counted characters, write counted bytes, i.e. - * size != sizeb */ + /* + * [Bug 2895565]. At this point 'size' still contains the number of + * bytes or characters which have been read. We keep this to later to + * update the totals and toRead information, see marker (UP) below. We + * must not overwrite it with 'sizeb', which is the number of written + * bytes or characters, and both EOL translation and encoding + * conversion may have changed this number unpredictably in relation + * to 'size' (It can be smaller or larger, in the latter case able to + * drive toRead below -1, causing infinite looping). Completely + * unsuitable for updating totals and toRead. + */ if (sizeb < 0) { writeError: @@ -8755,7 +8758,7 @@ CopyData( } /* - * Update the current byte count. Do it now so the count is valid + * (UP) Update the current byte count. Do it now so the count is valid * before a return or break takes us out of the loop. The invariant at * the top of the loop should be that csPtr->toRead holds the number * of bytes left to copy. |