Bug 10463

Summary: miInitIndex(): Conditional jump or move depends on uninitialised value(s)
Product: xorg Reporter: Chris Wilson <chris>
Component: * OtherAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium CC: esigra
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 10101    
Attachments:
Description Flags
Intialize pixel to zero before AllocColor none

Description Chris Wilson 2007-03-29 13:14:10 UTC
valgrinding Xvfb warns about:
==14535== Conditional jump or move depends on uninitialised value(s)
==14535==    at 0x806374C: FindColor (colormap.c:1226)
==14535==    by 0x8065888: AllocColor (colormap.c:912)
==14535==    by 0x831BFE0: miInitIndexed (miindex.c:153)
==14535==    by 0x831170F: PictureInitIndexedFormats (picture.c:485)
==14535==    by 0x8311781: PictureFinishInit (picture.c:502)
==14535==    by 0x8318E98: RenderExtensionInit (render.c:248)
==14535==    by 0x8061A74: InitExtensions (miinitext.c:646)
==14535==    by 0x808180E: main (main.c:379)
==14535== 

The fix is trivial:
--- a/render/miindex.c
+++ b/render/miindex.c
@@ -147,6 +147,7 @@ miBuildRenderColormap (ColormapPtr  pColormap, Pixel *pixels
        for (g = 0; g < cube; g++)
            for (b = 0; b < cube; b++)
            {
+               pixel = 0;
                red = (r * 65535 + (cube-1)/2) / (cube - 1);
                green = (g * 65535 + (cube-1)/2) / (cube - 1);
                blue = (b * 65535 + (cube-1)/2) / (cube - 1);
@@ -157,6 +158,7 @@ miBuildRenderColormap (ColormapPtr  pColormap, Pixel *pixels
            }
     for (g = 0; g < gray; g++)
     {
+       pixel = 0;
        red = green = blue = (g * 65535 + (gray-1)/2) / (gray - 1);
        if (AllocColor (pColormap, &red, &green, &blue, &pixel, 0) != Success)
            return FALSE;
Comment 1 Chris Wilson 2007-03-29 13:51:53 UTC
Created attachment 9362 [details] [review]
Intialize pixel to zero before AllocColor
Comment 2 Adam Jackson 2008-02-29 13:41:09 UTC
Fixed in git, thanks!

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.