glx/dri: Initialize api even if num_attribs == 0.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 11 Jan 2012 07:32:50 +0000 (23:32 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 11 Jan 2012 20:13:49 +0000 (12:13 -0800)
Both dri2_create_context_attribs and drisw_create_context_attribs call
dri2_convert_glx_attribs, expecting it to fill in *api on success.

However, when num_attribs == 0, it was returning true without setting
*api, causing the caller to use an uninitialized value.

Tested-by: Vadim Girlin <vadimgirlin@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
src/glx/dri_common.c

index 8feb58777b86fd487cade818d1304195da9f530a..ed0b134f00b4a8ab10f2f693a8edfebaf2fc9c28 100644 (file)
@@ -429,8 +429,10 @@ dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
    uint32_t profile;
    int render_type = GLX_RGBA_TYPE;
 
-   if (num_attribs == 0)
+   if (num_attribs == 0) {
+      *api = __DRI_API_OPENGL;
       return true;
+   }
 
    /* This is actually an internal error, but what the heck.
     */