| Description: |
Description of problem:
A stack-allocated structure is used as a hash key for a color in
Tk_GetColorByValue(). Compilation on x86_64 inserts some unused gaps in
structures for alignment: this results in having undefined bits participating
to the hash code computation, introducing the risk of missing a color that is
already in the table.
Version-Release number of selected component (if applicable):
tk-8.5.7-2.fc12.x86_64
How reproducible:
No recipe: very random in nature.
I discovered this problem inadvertently while using valgrind on "insight" for
another problem.
Additional info:
The attached patch fixes this problem by clearing the structure before
assigning its fields.
---------------------------------
diff -Naur tk8.5.7.orig/generic/tkColor.c tk8.5.7.new/generic/tkColor.c
--- tk8.5.7.orig/generic/tkColor.c2007-12-13 16:24:13.000000000 +0100
+++ tk8.5.7.new/generic/tkColor.c2009-12-09 12:20:39.000000000 +0100
@@ -302,6 +302,7 @@
* First, check to see if there's already a mapping for this color name.
*/
+ memset(&valueKey, 0, sizeof(valueKey));/* Clear interfield gaps. */
valueKey.red = colorPtr->red;
valueKey.green = colorPtr->green;
valueKey.blue = colorPtr->blue;
|