summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2014-06-06 08:47:28 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2014-06-06 08:47:28 (GMT)
commit0fbfb196c3b93d788a90aecc5b76dfedbbd9f007 (patch)
treedff5d9f3c2c974f42cd0505197ea7154bf5cd6f7 /generic
parent0564f2716f8b04442e7d62edc49e651dcff09126 (diff)
parent1839434f32f737c9fb5c3eb0ebec71b3cccfb581 (diff)
downloadtcl-0fbfb196c3b93d788a90aecc5b76dfedbbd9f007.zip
tcl-0fbfb196c3b93d788a90aecc5b76dfedbbd9f007.tar.gz
tcl-0fbfb196c3b93d788a90aecc5b76dfedbbd9f007.tar.bz2
merge trunk
Diffstat (limited to 'generic')
-rw-r--r--generic/tclIO.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 9197b06..6add83f 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -6016,10 +6016,13 @@ ReadChars(
/*
* We read more chars than allowed. Reset limits to
- * prevent that and try again.
+ * prevent that and try again. Don't forget the extra
+ * padding of TCL_UTF_MAX - 1 bytes demanded by the
+ * Tcl_ExternalToUtf() call!
*/
- dstLimit = Tcl_UtfAtIndex(dst, charsToRead + 1) - dst;
+ dstLimit = Tcl_UtfAtIndex(dst, charsToRead + 1)
+ + TCL_UTF_MAX - 1 - dst;
statePtr->flags = savedFlags;
statePtr->inputEncodingFlags = savedIEFlags;
statePtr->inputEncodingState = savedState;
@@ -6097,8 +6100,12 @@ ReadChars(
consume:
bufPtr->nextRemoved += srcRead;
- if (dstWrote > srcRead + 1) {
- *factorPtr = dstWrote * UTF_EXPANSION_FACTOR / srcRead;
+ /*
+ * If this read contained multibyte characters, revise factorPtr
+ * so the next read will allocate bigger buffers.
+ */
+ if (numChars && numChars < srcRead) {
+ *factorPtr = srcRead * UTF_EXPANSION_FACTOR / numChars;
}
Tcl_SetObjLength(objPtr, numBytes + dstWrote);
return numChars;