summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
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: