summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2009-03-21 02:53:17 (GMT)
committerdgp <dgp@users.sourceforge.net>2009-03-21 02:53:17 (GMT)
commit495e84429c8bf25d60aa8194541575305b393c45 (patch)
tree5ec5f24bbefd332a7404fbb73c76d154d7653409
parenta8d345d8f8f69ab77a2110e5838f61475ec15c8f (diff)
downloadtcl-495e84429c8bf25d60aa8194541575305b393c45.zip
tcl-495e84429c8bf25d60aa8194541575305b393c45.tar.gz
tcl-495e84429c8bf25d60aa8194541575305b393c45.tar.bz2
* generic/tclStringObj.c: Test stringObj-6.9 checks that
* tests/stringObj.test: Tcl_AppendStringsToObj() no longer crashes when operating on a pure unicode value. [Bug 2597185]
-rw-r--r--ChangeLog4
-rw-r--r--generic/tclStringObj.c10
-rw-r--r--tests/stringObj.test8
3 files changed, 19 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 5fd15a7..91f30ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2009-03-20 Don Porter <dgp@users.sourceforge.net>
+ * generic/tclStringObj.c: Test stringObj-6.9 checks that
+ * tests/stringObj.test: Tcl_AppendStringsToObj() no longer
+ crashes when operating on a pure unicode value. [Bug 2597185]
+
* generic/tclExecute.c (INST_CONCAT1): Panic when appends overflow
the max length of a Tcl value. [Bug 2669109]
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 8d5bb6f..32197a7 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -33,7 +33,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclStringObj.c,v 1.32.2.6 2009/02/05 14:10:58 dgp Exp $ */
+ * RCS: @(#) $Id: tclStringObj.c,v 1.32.2.7 2009/03/21 02:53:18 dgp Exp $ */
#include "tclInt.h"
@@ -1473,6 +1473,13 @@ Tcl_AppendStringsToObjVA (objPtr, argList)
SetStringFromAny(NULL, objPtr);
/*
+ * Force the existence of a string rep. so we avoid crashes operating
+ * on a pure unicode value. [Bug 2597185]
+ */
+
+ (void) Tcl_GetStringFromObj(objPtr, &oldLength);
+
+ /*
* Figure out how much space is needed for all the strings, and
* expand the string representation if it isn't big enough. If no
* bytes would be appended, just return. Note that on some platforms
@@ -1481,7 +1488,6 @@ Tcl_AppendStringsToObjVA (objPtr, argList)
nargs = 0;
newLength = 0;
- oldLength = objPtr->length;
while (1) {
string = va_arg(argList, char *);
if (string == NULL) {
diff --git a/tests/stringObj.test b/tests/stringObj.test
index e3bdbee..359e11a 100644
--- a/tests/stringObj.test
+++ b/tests/stringObj.test
@@ -12,7 +12,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: stringObj.test,v 1.15 2003/02/11 18:46:33 hobbs Exp $
+# RCS: @(#) $Id: stringObj.test,v 1.15.2.1 2009/03/21 02:53:18 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -165,6 +165,12 @@ test stringObj-6.8 {Tcl_AppendStringsToObj procedure, object totally empty} {
teststringobj appendstrings 1 {}
list [teststringobj length2 1] [teststringobj get 1]
} {0 {}}
+test stringObj-6.9 {Tcl_AppendStringToObj, pure unicode} {
+ testobj freeallvars
+ teststringobj set2 1 [string replace abc 1 1 d]
+ teststringobj appendstrings 1 foo bar soom
+ teststringobj get 1
+} adcfoobarsoom
test stringObj-7.1 {SetStringFromAny procedure} {
testobj freeallvars