From 526787f45e75e5f6fb736b3f4b3938ec4eaf2c44 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 10 Feb 2009 14:59:34 +0000 Subject: * generic/tclStringObj.c: Reduce code duplication in Tcl_GetUnicode*. Restrict AppendUtfToUtfRep to non-negative length appends. --- ChangeLog | 3 ++- generic/tclStringObj.c | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4a15b01..5a24360 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2009-02-10 Don Porter - * generic/tclStringObj.c (Tcl_GetUnicode*): Reduce code duplication. + * generic/tclStringObj.c: Reduce code duplication in Tcl_GetUnicode*. + Restrict AppendUtfToUtfRep to non-negative length appends. 2009-02-09 Jan Nijtmans diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index da17c2f..f74f90b 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.88 2009/02/10 14:38:55 dgp Exp $ */ + * RCS: @(#) $Id: tclStringObj.c,v 1.89 2009/02/10 14:59:34 dgp Exp $ */ #include "tclInt.h" #include "tommath.h" @@ -1146,7 +1146,7 @@ Tcl_AppendLimitedToObj( if (stringPtr->hasUnicode != 0) { AppendUtfToUnicodeRep(objPtr, ellipsis, -1); } else { - AppendUtfToUtfRep(objPtr, ellipsis, -1); + AppendUtfToUtfRep(objPtr, ellipsis, strlen(ellipsis)); } } @@ -1518,6 +1518,7 @@ AppendUtfToUnicodeRep( * * This function appends "numBytes" bytes of "bytes" to the UTF string * rep of "objPtr". objPtr must already have a valid String rep. + * numBytes must be non-negative. * * Results: * None. @@ -1537,9 +1538,6 @@ AppendUtfToUtfRep( String *stringPtr; int newLength, oldLength; - if (numBytes < 0) { - numBytes = (bytes ? strlen(bytes) : 0); - } if (numBytes == 0) { return; } -- cgit v0.12