summaryrefslogtreecommitdiffstats
path: root/generic/tclStringObj.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2003-02-11 18:35:05 (GMT)
committerhobbs <hobbs>2003-02-11 18:35:05 (GMT)
commit510815200ad3a5a5f455dc224faef6614393190f (patch)
tree8df742aebb536b43e35b6ea5e22eb4ced15d0634 /generic/tclStringObj.c
parent67d73535aad14b1646571c25e82db621225bbace (diff)
downloadtcl-510815200ad3a5a5f455dc224faef6614393190f.zip
tcl-510815200ad3a5a5f455dc224faef6614393190f.tar.gz
tcl-510815200ad3a5a5f455dc224faef6614393190f.tar.bz2
* tests/stringObj.test:
* generic/tclStringObj.c (Tcl_GetCharLength): correct ascii char opt of 2002-11-11 to not stop early on \x00. [Bug #684699]
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r--generic/tclStringObj.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 4af164c..41ecf137 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.28 2003/01/24 11:59:29 vincentdarley Exp $ */
+ * RCS: @(#) $Id: tclStringObj.c,v 1.29 2003/02/11 18:35:11 hobbs Exp $ */
#include "tclInt.h"
@@ -376,7 +376,7 @@ Tcl_GetCharLength(objPtr)
*/
if (stringPtr->numChars == -1) {
- register int i = 0;
+ register int i = 0, len = objPtr->length;
register unsigned char *str = (unsigned char *) objPtr->bytes;
/*
@@ -386,14 +386,13 @@ Tcl_GetCharLength(objPtr)
stringPtr->numChars = Tcl_NumUtfChars(objPtr->bytes, objPtr->length);
*/
- while (*str && *str < 0xC0) { i++; str++; }
+ while ((i < len) && (*str < 0xC0)) { i++; str++; }
stringPtr->numChars = i;
- if (*str) {
- stringPtr->numChars += Tcl_NumUtfChars(objPtr->bytes + i,
- objPtr->length - i);
+ if (i < len) {
+ stringPtr->numChars += Tcl_NumUtfChars(objPtr->bytes + i, len - i);
}
- if (stringPtr->numChars == objPtr->length) {
+ if (stringPtr->numChars == len) {
/*
* Since we've just calculated the number of chars, and all