summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjenglish <jenglish@flightlab.com>2008-07-04 19:06:02 (GMT)
committerjenglish <jenglish@flightlab.com>2008-07-04 19:06:02 (GMT)
commit2522c1a958eb895f1e4d576207c643353960ee56 (patch)
treecdbb2a1f76fc7db31e619a48557007d96f1744bc
parentfded95f4e881432bcd0b9bb27baf0aad2ad99be9 (diff)
downloadtk-2522c1a958eb895f1e4d576207c643353960ee56.zip
tk-2522c1a958eb895f1e4d576207c643353960ee56.tar.gz
tk-2522c1a958eb895f1e4d576207c643353960ee56.tar.bz2
Audit: ensure that output arguments to Tk_Get*FromObj() are initialized,
in case of erroneous style specifications [#2009213].
-rw-r--r--ChangeLog6
-rw-r--r--generic/ttk/ttkClamTheme.c10
-rw-r--r--generic/ttk/ttkClassicTheme.c10
-rw-r--r--generic/ttk/ttkDefaultTheme.c4
-rw-r--r--generic/ttk/ttkElements.c8
-rw-r--r--tests/ttk/ttk.test9
6 files changed, 30 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 640ad80..85dbf27 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-07-04 Joe English <jenglish@users.sourceforge.net>
+
+ * generic/ttk/ttkDefaultTheme.c, generic/ttk/ttkClamTheme.c,
+ generic/ttk/ttkClassicTheme.c, generic/ttk/ttkElements.c:
+ Backport [Bug 2009213].
+
2008-06-29 Don Porter <dgp@users.sourceforge.net>
*** 8.5.3 TAGGED FOR RELEASE ***
diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c
index cabdef3..2557046 100644
--- a/generic/ttk/ttkClamTheme.c
+++ b/generic/ttk/ttkClamTheme.c
@@ -1,5 +1,5 @@
/*
- * $Id: ttkClamTheme.c,v 1.9 2007/12/13 15:26:26 dgp Exp $
+ * $Id: ttkClamTheme.c,v 1.9.2.1 2008/07/04 19:06:03 jenglish Exp $
*
* Copyright (C) 2004 Joe English
*
@@ -487,7 +487,7 @@ static void GripElementSize(
{
int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
GripElement *grip = elementRecord;
- int gripCount;
+ int gripCount = 0;
Tcl_GetIntFromObj(NULL, grip->gripCountObj, &gripCount);
if (horizontal) {
@@ -506,8 +506,8 @@ static void GripElementDraw(
GripElement *grip = elementRecord;
GC lightGC = Ttk_GCForColor(tkwin,grip->lightColorObj,d);
GC darkGC = Ttk_GCForColor(tkwin,grip->borderColorObj,d);
- int gripPad = 1;
- int i, gripCount;
+ int gripPad = 1, gripCount = 0;
+ int i;
Tcl_GetIntFromObj(NULL, grip->gripCountObj, &gripCount);
@@ -614,7 +614,7 @@ static void ThumbElementDraw(
Drawable d, Ttk_Box b, unsigned state)
{
ScrollbarElement *sb = elementRecord;
- int gripCount = 3, orient = TTK_ORIENT_HORIZONTAL;
+ int gripCount = 0, orient = TTK_ORIENT_HORIZONTAL;
GC lightGC, darkGC;
int x1, y1, x2, y2, dx, dy, i;
const int w = WIN32_XDRAWLINE_HACK;
diff --git a/generic/ttk/ttkClassicTheme.c b/generic/ttk/ttkClassicTheme.c
index e2f3651..f71ca30 100644
--- a/generic/ttk/ttkClassicTheme.c
+++ b/generic/ttk/ttkClassicTheme.c
@@ -1,5 +1,5 @@
/*
- * $Id: ttkClassicTheme.c,v 1.6 2007/12/13 15:26:26 dgp Exp $
+ * $Id: ttkClassicTheme.c,v 1.6.2.1 2008/07/04 19:06:03 jenglish Exp $
*
* Copyright (c) 2004, Joe English
*
@@ -228,17 +228,15 @@ static void ArrowElementDraw(
{
int direction = *(int *)clientData;
ArrowElement *arrow = elementRecord;
- Tk_3DBorder border;
- int borderWidth;
+ Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
+ int borderWidth = 2;
int relief = TK_RELIEF_RAISED;
- int size;
+ int size = b.width < b.height ? b.width : b.height;
XPoint points[3];
Tk_GetPixelsFromObj(NULL, tkwin, arrow->borderWidthObj, &borderWidth);
- border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief);
- size = b.width < b.height ? b.width : b.height;
/*
* @@@ There are off-by-one pixel errors in the way these are drawn;
diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c
index bfc3af1..118934e 100644
--- a/generic/ttk/ttkDefaultTheme.c
+++ b/generic/ttk/ttkDefaultTheme.c
@@ -1,4 +1,4 @@
-/* $Id: ttkDefaultTheme.c,v 1.11 2007/12/13 15:26:26 dgp Exp $
+/* $Id: ttkDefaultTheme.c,v 1.11.2.1 2008/07/04 19:06:03 jenglish Exp $
*
* Copyright (c) 2003, Joe English
*
@@ -826,7 +826,7 @@ static void TroughElementDraw(
{
TroughElement *troughPtr = elementRecord;
Tk_3DBorder border = NULL;
- int borderWidth = 2, relief, groove, orient;
+ int borderWidth = 2, relief = TK_RELIEF_SUNKEN, groove = -1, orient;
border = Tk_Get3DBorderFromObj(tkwin, troughPtr->colorObj);
Ttk_GetOrientFromObj(NULL, troughPtr->orientObj, &orient);
diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c
index 78d314d..648bbc4 100644
--- a/generic/ttk/ttkElements.c
+++ b/generic/ttk/ttkElements.c
@@ -1,4 +1,4 @@
-/* $Id: ttkElements.c,v 1.10 2007/12/13 15:26:26 dgp Exp $
+/* $Id: ttkElements.c,v 1.10.2.1 2008/07/04 19:06:03 jenglish Exp $
*
* Copyright (c) 2003, Joe English
*
@@ -957,7 +957,7 @@ static void SliderElementDraw(
{
SliderElement *slider = elementRecord;
Tk_3DBorder border = NULL;
- int relief, borderWidth, orient;
+ int relief = TK_RELIEF_RAISED, borderWidth = 2, orient;
border = Tk_Get3DBorderFromObj(tkwin, slider->borderObj);
Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient);
@@ -1043,7 +1043,7 @@ static void PbarElementSize(
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
PbarElement *pbar = elementRecord;
- int orient, thickness, length, borderWidth;
+ int orient, thickness = 15, length = 30, borderWidth = 2;
Ttk_GetOrientFromObj(NULL, pbar->orientObj, &orient);
Tk_GetPixelsFromObj(NULL, tkwin, pbar->thicknessObj, &thickness);
@@ -1068,7 +1068,7 @@ static void PbarElementDraw(
{
PbarElement *pbar = elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, pbar->borderObj);
- int relief, borderWidth;
+ int relief = TK_RELIEF_RAISED, borderWidth = 2;
Tk_GetPixelsFromObj(NULL, tkwin, pbar->borderWidthObj, &borderWidth);
Tk_GetReliefFromObj(NULL, pbar->reliefObj, &relief);
diff --git a/tests/ttk/ttk.test b/tests/ttk/ttk.test
index fab6c2c..a1430ff 100644
--- a/tests/ttk/ttk.test
+++ b/tests/ttk/ttk.test
@@ -191,6 +191,15 @@ test ttk-3.2 "Propagate errors from variable traces" -body {
unset ::A ; destroy .cb
} -returnCodes error -result {can't set "A": failure}
+test ttk-3.4 "SF#2009213" -body {
+ ttk::style configure TScale -sliderrelief {}
+ pack [ttk::scale .s]
+ update
+} -cleanup {
+ ttk::style configure TScale -sliderrelief raised
+ destroy .s
+}
+
# Test resource allocation
# (@@@ "-font" is a compatibility option now, so tests 4.1-4.3
# don't really test anything useful at the moment.)