[Mesa-dev] [PATCH] glx/dri2: fix use of uninitialized variable "api"
Kenneth Graunke
kenneth at whitecape.org
Tue Jan 10 23:32:15 PST 2012
On 01/10/2012 09:32 PM, Vadim Girlin wrote:
> Signed-off-by: Vadim Girlin<vadimgirlin at gmail.com>
> ---
>
> Fixes unigine heaven startup problem for me.
>
> src/glx/dri2_glx.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
> index 10b6f52..b4efa40 100644
> --- a/src/glx/dri2_glx.c
> +++ b/src/glx/dri2_glx.c
> @@ -240,7 +240,7 @@ dri2_create_context_attribs(struct glx_screen *base,
> uint32_t minor_ver = 1;
> uint32_t major_ver = 2;
> uint32_t flags = 0;
> - unsigned api;
> + unsigned api = __DRI_API_OPENGL;
> uint32_t ctx_attribs[2 * 4];
> unsigned num_ctx_attribs = 0;
Ah, I see the problem now:
We pass &api to dri2_convert_glx_attribs, which is supposed to fill it
in unless it returns false (failure). However, in the case where
num_attribs == 0, it does this:
if (num_attribs == 0)
return true;
...without setting *api. I think it would be better to fix the bug in
dri2_convert_glx_attribs() by changing that to
if (num_attribs == 0) {
*api = __DRI_API_OPENGL;
return true;
}
rather than working around the broken function here in the caller.
Notably, drisw_create_context_attribs suffers from the exact same bug;
fixing it in dri2_convert_glx_attribs would fix both.
Unfortunately, Heaven still gives me bizarre X errors, even with this
patch. I'll have to investigate further.
More information about the mesa-dev
mailing list