summaryrefslogtreecommitdiffstats
path: root/generic/tclStringObj.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2012-02-09 14:57:14 (GMT)
committerdgp <dgp@users.sourceforge.net>2012-02-09 14:57:14 (GMT)
commite808998f32299b76b5d72c1eeab0c61d7b39912e (patch)
treef7303d89da1537038ab6344ab79bf0542112cf5f /generic/tclStringObj.c
parent99a82a1d2a04b642287809eb986c0a70820cbe1e (diff)
parentc5427831dfb603ba16dfcc06ff2e4df0babe639e (diff)
downloadtcl-e808998f32299b76b5d72c1eeab0c61d7b39912e.zip
tcl-e808998f32299b76b5d72c1eeab0c61d7b39912e.tar.gz
tcl-e808998f32299b76b5d72c1eeab0c61d7b39912e.tar.bz2
3484402 Correct Off-By-One error appending unicode. Thanks to Poor Yorick.
Also corrected test for when growth is needed.
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r--generic/tclStringObj.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index b5b3674..7005223 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -1308,7 +1308,7 @@ AppendUnicodeToUnicodeRep(objPtr, unicode, appendNumChars)
numChars = stringPtr->numChars + appendNumChars;
stringCheckLimits(numChars);
- if (STRING_UALLOC(numChars) >= stringPtr->uallocated) {
+ if (STRING_UALLOC(numChars) > stringPtr->uallocated) {
/*
* Protect against case where unicode points into the existing
* stringPtr->unicode array. Force it to follow any relocations
@@ -1316,7 +1316,7 @@ AppendUnicodeToUnicodeRep(objPtr, unicode, appendNumChars)
*/
int offset = -1;
if (unicode >= stringPtr->unicode && unicode <= stringPtr->unicode
- + 1 + stringPtr->uallocated / sizeof(Tcl_UniChar)) {
+ + stringPtr->uallocated / sizeof(Tcl_UniChar)) {
offset = unicode - stringPtr->unicode;
}