summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tkScale.c11
-rw-r--r--tests/scale.test1
2 files changed, 9 insertions, 3 deletions
diff --git a/generic/tkScale.c b/generic/tkScale.c
index 28e5b16..258a1fa 100644
--- a/generic/tkScale.c
+++ b/generic/tkScale.c
@@ -632,7 +632,12 @@ ConfigureScale(
scalePtr->tickInterval = -scalePtr->tickInterval;
}
- ComputeFormat(scalePtr);
+ if (scalePtr->digits > TCL_MAX_PREC) {
+ Tcl_AppendResult(interp, "too large -digits value", NULL);
+ continue;
+ } else {
+ ComputeFormat(scalePtr);
+ }
scalePtr->labelLength = scalePtr->label ? (int)strlen(scalePtr->label) : 0;
@@ -888,7 +893,7 @@ static void
ComputeScaleGeometry(
register TkScale *scalePtr) /* Information about widget. */
{
- char valueString[PRINT_CHARS];
+ char valueString[TCL_DOUBLE_SPACE];
int tmp, valuePixels, x, y, extraSpace;
Tk_FontMetrics fm;
@@ -1304,7 +1309,7 @@ ScaleSetVariable(
register TkScale *scalePtr) /* Info about widget. */
{
if (scalePtr->varNamePtr != NULL) {
- char string[PRINT_CHARS];
+ char string[TCL_DOUBLE_SPACE];
sprintf(string, scalePtr->format, scalePtr->value);
scalePtr->flags |= SETTING_VAR;
diff --git a/tests/scale.test b/tests/scale.test
index 657f668..527b319 100644
--- a/tests/scale.test
+++ b/tests/scale.test
@@ -35,6 +35,7 @@ foreach test {
{-command "set x" {set x} {} {}}
{-cursor arrow arrow badValue {bad cursor spec "badValue"}}
{-digits 5 5 badValue {expected integer but got "badValue"}}
+ {-digits 17 17 18 {too large -digits value}}
{-fg #00ff00 #00ff00 badValue {unknown color name "badValue"}}
{-font fixed fixed {} {font "" doesn't exist}}
{-foreground green green badValue {unknown color name "badValue"}}