From: Kenneth Graunke Date: Wed, 11 Jan 2012 07:32:50 +0000 (-0800) Subject: glx/dri: Initialize api even if num_attribs == 0. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=10a6fde333f0170fbac70924581c647e531aba3e;p=mesa.git glx/dri: Initialize api even if num_attribs == 0. 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 Reviewed-by: Ian Romanick Signed-off-by: Kenneth Graunke --- diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c index 8feb58777b8..ed0b134f00b 100644 --- a/src/glx/dri_common.c +++ b/src/glx/dri_common.c @@ -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. */