summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2017-10-22 19:34:00 (GMT)
committerfvogel <fvogelnew1@free.fr>2017-10-22 19:34:00 (GMT)
commit3e2c6e96cb35dde5fa8a7eb932bf0332067231a5 (patch)
treeff0eda52bc839147f11e6fa509ed5399f055c0e0 /unix
parent2fef4593c8cce3a56ff02136657d930af6eb2abd (diff)
parent20a05b8bc7cbd7e31d4fd0f094d3849945118a77 (diff)
downloadtk-3e2c6e96cb35dde5fa8a7eb932bf0332067231a5.zip
tk-3e2c6e96cb35dde5fa8a7eb932bf0332067231a5.tar.gz
tk-3e2c6e96cb35dde5fa8a7eb932bf0332067231a5.tar.bz2
Fix [55b95f578a]: Associating variable with bignum value with scale crashes it.
Diffstat (limited to 'unix')
-rw-r--r--unix/tkUnixScale.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/unix/tkUnixScale.c b/unix/tkUnixScale.c
index c348037..8f88018 100644
--- a/unix/tkUnixScale.c
+++ b/unix/tkUnixScale.c
@@ -13,6 +13,10 @@
#include "tkInt.h"
#include "tkScale.h"
+#if defined(_WIN32)
+#define snprintf _snprintf
+#endif
+
/*
* Forward declarations for functions defined later in this file:
*/
@@ -267,7 +271,9 @@ DisplayVerticalValue(
Tk_GetFontMetrics(scalePtr->tkfont, &fm);
y = TkScaleValueToPixel(scalePtr, value) + fm.ascent/2;
- sprintf(valueString, scalePtr->format, value);
+ if (snprintf(valueString, TCL_DOUBLE_SPACE, scalePtr->format, value) < 0) {
+ valueString[TCL_DOUBLE_SPACE - 1] = '\0';
+ }
length = (int) strlen(valueString);
width = Tk_TextWidth(scalePtr->tkfont, valueString, length);
@@ -352,7 +358,10 @@ DisplayHorizontalScale(
ticks = fabs((scalePtr->toValue - scalePtr->fromValue)
/ tickInterval);
- sprintf(valueString, scalePtr->format, scalePtr->fromValue);
+ if (snprintf(valueString, TCL_DOUBLE_SPACE, scalePtr->format,
+ scalePtr->fromValue) < 0) {
+ valueString[TCL_DOUBLE_SPACE - 1] = '\0';
+ }
maxTicks = (double) Tk_Width(tkwin)
/ (double) Tk_TextWidth(scalePtr->tkfont, valueString, -1);
if (ticks > maxTicks) {
@@ -484,7 +493,9 @@ DisplayHorizontalValue(
x = TkScaleValueToPixel(scalePtr, value);
Tk_GetFontMetrics(scalePtr->tkfont, &fm);
y = top + fm.ascent;
- sprintf(valueString, scalePtr->format, value);
+ if (snprintf(valueString, TCL_DOUBLE_SPACE, scalePtr->format, value) < 0) {
+ valueString[TCL_DOUBLE_SPACE - 1] = '\0';
+ }
length = (int) strlen(valueString);
width = Tk_TextWidth(scalePtr->tkfont, valueString, length);
@@ -551,7 +562,10 @@ TkpDisplayScale(
Tcl_Preserve(scalePtr);
if ((scalePtr->flags & INVOKE_COMMAND) && (scalePtr->command != NULL)) {
Tcl_Preserve(interp);
- sprintf(string, scalePtr->format, scalePtr->value);
+ if (snprintf(string, TCL_DOUBLE_SPACE, scalePtr->format,
+ scalePtr->value) < 0) {
+ string[TCL_DOUBLE_SPACE - 1] = '\0';
+ }
Tcl_DStringInit(&buf);
Tcl_DStringAppend(&buf, scalePtr->command, -1);
Tcl_DStringAppend(&buf, " ", -1);