summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorhobbs <hobbs@noemail.net>2003-02-11 18:35:05 (GMT)
committerhobbs <hobbs@noemail.net>2003-02-11 18:35:05 (GMT)
commit14179fb4eae5973107715a28f57e605c4d322cbe (patch)
tree8df742aebb536b43e35b6ea5e22eb4ced15d0634 /generic
parent94e70eb3bf9c327ee88c65a5e2217a0ba9f4e4b2 (diff)
downloadtcl-14179fb4eae5973107715a28f57e605c4d322cbe.zip
tcl-14179fb4eae5973107715a28f57e605c4d322cbe.tar.gz
tcl-14179fb4eae5973107715a28f57e605c4d322cbe.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] FossilOrigin-Name: 78c313648a51143f0ac2e1dc15eb1c74709f0d8e
Diffstat (limited to 'generic')
-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