From 71048d27d0a64c0fa11da33a09037c820babf6e5 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 31 Jul 2009 16:55:58 +0000 Subject: * generic/tclStringObj.c: Corrected failure to grow buffer * tests/format.test: when format spec request large width floating point values. Thanks to Clemens Misch. [Bug 2830354] --- ChangeLog | 6 ++++++ generic/tclStringObj.c | 5 ++++- tests/format.test | 6 +++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f907b8d..b3463a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-07-31 Don Porter + + * generic/tclStringObj.c: Corrected failure to grow buffer + * tests/format.test: when format spec request large width + floating point values. Thanks to Clemens Misch. [Bug 2830354] + 2009-07-26 Donal K. Fellows * library/auto.tcl (tcl_findLibrary, auto_mkindex): diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 7804e1f..9ba62f5 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.127 2009/07/12 18:04:33 dkf Exp $ */ + * RCS: @(#) $Id: tclStringObj.c,v 1.128 2009/07/31 16:55:58 dgp Exp $ */ #include "tclInt.h" #include "tommath.h" @@ -2211,6 +2211,9 @@ Tcl_AppendFormatToObj( } if (width) { p += sprintf(p, "%d", width); + if (width > length) { + length = width; + } } if (gotPrecision) { *p++ = '.'; diff --git a/tests/format.test b/tests/format.test index d2cbcde..8aa7d0b 100644 --- a/tests/format.test +++ b/tests/format.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: format.test,v 1.28 2008/12/10 18:21:47 ferrieux Exp $ +# RCS: @(#) $Id: format.test,v 1.29 2009/07/31 16:55:58 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -566,6 +566,10 @@ test format-19.2 {Bug 1867855} { format %llx 0 } 0 +test format-19.3 {Bug 2830354} { + string length [format %340f 0] +} 340 + # cleanup catch {unset a} catch {unset b} -- cgit v0.12