summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp@users.sourceforge.net <dgp>2012-02-09 15:00:46 (GMT)
committerdgp@users.sourceforge.net <dgp>2012-02-09 15:00:46 (GMT)
commit8872c3a3f37f6f339b49f0fe332c8148c752c56f (patch)
tree62b0ddf0cdb20a546d439a7a60a4f5853f9c8871
parent378948f519afcc4504f8dad73cbfc92e986a363c (diff)
parenteebbfd0fa7c88a264fdf7e493dff0e4d70adb183 (diff)
downloadtcl-8872c3a3f37f6f339b49f0fe332c8148c752c56f.zip
tcl-8872c3a3f37f6f339b49f0fe332c8148c752c56f.tar.gz
tcl-8872c3a3f37f6f339b49f0fe332c8148c752c56f.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 a14821a..f659f89 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/tclCompCmds.c: [Bug 3485022] TclCompileEnsemble() avoid
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 13dda54..3f243a6 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -1379,7 +1379,7 @@ AppendUnicodeToUnicodeRep(
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
@@ -1387,7 +1387,7 @@ AppendUnicodeToUnicodeRep(
*/
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;
}