summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclObj.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/generic/tclObj.c b/generic/tclObj.c
index 4f7194b..72c2340 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -1769,6 +1769,11 @@ Tcl_InitStringRep(
}
} else {
/* objPtr->bytes != NULL bytes == NULL - Truncate */
+ assert(numBytes <= objPtr->length);
+ if (objPtr->length > numBytes) {
+ objPtr->bytes = (char *)ckrealloc(objPtr->bytes,
+ (unsigned)(numBytes+1));
+ }
objPtr->length = numBytes;
}