diff options
author | dgp <dgp@users.sourceforge.net> | 2016-03-23 10:10:10 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2016-03-23 10:10:10 (GMT) |
commit | cae0944edaf0979a05c2dab80d18f6434b0b306e (patch) | |
tree | 8527bca68b32daaf631012c4b5676bfa249df986 /generic/tclObj.c | |
parent | 37f5c2af038e71d1c88fe0fcb9d061b6c620dec0 (diff) | |
download | tcl-cae0944edaf0979a05c2dab80d18f6434b0b306e.zip tcl-cae0944edaf0979a05c2dab80d18f6434b0b306e.tar.gz tcl-cae0944edaf0979a05c2dab80d18f6434b0b306e.tar.bz2 |
Release memory after truncation.
Diffstat (limited to 'generic/tclObj.c')
-rw-r--r-- | generic/tclObj.c | 5 |
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; } |