diff options
author | das <das> | 2009-04-15 19:22:44 (GMT) |
---|---|---|
committer | das <das> | 2009-04-15 19:22:44 (GMT) |
commit | e400b768faa4a193feca790e846cc04cf3255b67 (patch) | |
tree | 2aed9f620b2ce62a4170af6e9ff46a5dd240dc68 /generic/tclStringObj.c | |
parent | 09ae5cf67030dc3cae909101f445157bdcf6aacd (diff) | |
download | tcl-e400b768faa4a193feca790e846cc04cf3255b67.zip tcl-e400b768faa4a193feca790e846cc04cf3255b67.tar.gz tcl-e400b768faa4a193feca790e846cc04cf3255b67.tar.bz2 |
UpdateStringOfString: matchup with core-8-5-branch changes
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r-- | generic/tclStringObj.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index aad8881..e6118c6 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.10 2009/04/15 19:11:07 dgp Exp $ */ + * RCS: @(#) $Id: tclStringObj.c,v 1.32.2.11 2009/04/15 19:22:44 das Exp $ */ #include "tclInt.h" @@ -1934,20 +1934,20 @@ UpdateStringOfString(objPtr) } size = 0; - for (i = 0; i < stringPtr->numChars; i++) { + for (i = 0; i < stringPtr->numChars && size >= 0; i++) { size += Tcl_UniCharToUtf((int) unicode[i], dummy); } if (size < 0) { Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX); } - - dst = (char *) ckalloc((unsigned) (size + 1)); - objPtr->bytes = dst; + + objPtr->bytes = (char *) ckalloc((unsigned) (size + 1)); objPtr->length = size; stringPtr->allocated = size; copyBytes: - for (i = 0; i < stringPtr->numChars && size >= 0; i++) { + dst = objPtr->bytes; + for (i = 0; i < stringPtr->numChars; i++) { dst += Tcl_UniCharToUtf(unicode[i], dst); } *dst = '\0'; |