Simply make it:

 vvp->background_gc = vik_viewport_new_gc ( vvp, DEFAULT_BACKGROUND_COLOR, 1);

and remove the following vik_viewport_set_background_color line.

Thus making it the same way as scale_bg_gc is setup just below (presumably in 
the correct manner).

=====

If colours are always set via the GUI ColorPicker they should never be "" (I 
hope!)
I suppose maybe a file could be hand modified to have strings of anything and 
so vikviewport.c colour functions could be made more robust to protect 
themselves from "" and non colour parsing names, perhaps using black as a fall 
back colour.

Be Seeing You - Rob.
If at first you don't succeed,
then skydiving isn't for you.


----------------------------------------
> From: jburgess...@gmail.com
> To: viking-devel@lists.sourceforge.net
> Date: Sun, 26 Sep 2010 23:07:28 +0100
> Subject: [Viking-devel] Uninitialized color value being used
>
> Valgrind pointed out another little case where uninitialized data may be
> used:
>
> ==7742== Conditional jump or move depends on uninitialised value(s)
> ==7742== at 0x3DF2E2109C: _XUpdateGCCache (in /usr/lib64/libX11.so.6.3.0)
> ==7742== by 0x3DF2E1E8BD: XChangeGC (in /usr/lib64/libX11.so.6.3.0)
> ==7742== by 0x3BD0262869: ??? (in /usr/lib64/libgdk-x11-2.0.so.0.2000.1)
> ==7742== by 0x3BD022786B: gdk_gc_set_foreground (in 
> /usr/lib64/libgdk-x11-2.0.so.0.2000.1)
> ==7742== by 0x3BD022792E: gdk_gc_set_rgb_fg_color (in 
> /usr/lib64/libgdk-x11-2.0.so.0.2000.1)
> ==7742== by 0x42B391: vik_viewport_new_gc (vikviewport.c:236)
> ==7742== by 0x42B5A1: vik_viewport_configure (vikviewport.c:293)
> ...
> ==7742== Uninitialised value was created by a stack allocation
> ==7742== at 0x42B340: vik_viewport_new_gc (vikviewport.c:230)
>
>
> I'm pretty sure this happens because of this code:
>
> vik_viewport_configure()
> {
> ...
> vvp->background_gc = vik_viewport_new_gc ( vvp, "", 1 );
>
>
> GdkGC *vik_viewport_new_gc ( ..., const gchar *colorname, ... )
> {
> GdkGC *rv;
> GdkColor color;
>
> rv = gdk_gc_new ( GTK_WIDGET(vvp)->window );
> gdk_color_parse ( colorname, &color );
> gdk_gc_set_rgb_fg_color ( rv, &color );
>
>
> What happens is that the lookup of the color named "" fails so
> gdk_color_parse() returns FALSE and fails to initialize the 'color'
> variable which then gets used later on to set the foreground color.
>
> There are perhaps two issues here, first it isn't clear what colour is
> being requested for "" and second the code could either pre-initialize
> color or set it to something sensible if the lookup fails.
>
> Jon

                                          
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Viking-devel mailing list
Viking-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/viking-devel
Viking home page: http://viking.sf.net/

Reply via email to