summaryrefslogtreecommitdiffstats
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)
commit7695d3270788d56c1ba433909285dcab42414edb (patch)
treef7303d89da1537038ab6344ab79bf0542112cf5f
parent5894df49560c27bd2e8a613912674b7f6392ae84 (diff)
parentff9b3b8ec7d147ac0092284c95bc1c804a9bb207 (diff)
downloadtcl-7695d3270788d56c1ba433909285dcab42414edb.zip
tcl-7695d3270788d56c1ba433909285dcab42414edb.tar.gz
tcl-7695d3270788d56c1ba433909285dcab42414edb.tar.bz2
3484402 Correct Off-By-One error appending unicode. Thanks to Poor Yorick.
Also corrected test for when growth is needed.
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclStringObj.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 5c46456..0dbd68c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-02-09 Don Porter <dgp@users.sourceforge.net>
+
+ * generic/tclStringObj.c: [Bug 3484402] Correct Off-By-One
+ error appending unicode. Thanks to Poor Yorick. Also corrected test
+ for when growth is needed.
+
2012-02-06 Don Porter <dgp@users.sourceforge.net>
* generic/tclCmdMZ.c: [Bug 3484621] Invalidate bytecode when exec
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;
}