summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-02-06 19:04:36 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-02-06 19:04:36 (GMT)
commit11b2556b272a74d9456a2b0b9cef5ccc76fd8316 (patch)
tree0200708c41644616f3064cf13f8525b0194b9899 /generic/tclIO.c
parent204a41c65d68c707c0b4e6114424444c59e75808 (diff)
downloadtcl-11b2556b272a74d9456a2b0b9cef5ccc76fd8316.zip
tcl-11b2556b272a74d9456a2b0b9cef5ccc76fd8316.tar.gz
tcl-11b2556b272a74d9456a2b0b9cef5ccc76fd8316.tar.bz2
Revised ReadChars to restore an attempt to make sure we do not short readdgp_may_be_pointless
because of a false notion of limited storage space. The test suite does not appear to demonstrate any case where this matters. Could be an incomplete test suite, or an example of pointless code.
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index f8baba3..cedf3f6 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -5310,7 +5310,13 @@ ReadChars(
dstNeeded = TCL_UTF_MAX - 1 + toRead * factor / UTF_EXPANSION_FACTOR;
(void) TclGetStringFromObj(objPtr, &numBytes);
Tcl_AppendToObj(objPtr, NULL, dstNeeded);
- dst = TclGetString(objPtr) + numBytes;
+ if (toRead == srcLen) {
+ unsigned int size;
+ dst = TclGetStringStorage(objPtr, &size) + numBytes;
+ dstNeeded = size - numBytes;
+ } else {
+ dst = TclGetString(objPtr) + numBytes;
+ }
/*
* [Bug 1462248]: The cause of the crash reported in this bug is this: