[Mesa-dev] [PATCH] glx: Check that swap_buffers_reply is non-NULL before using it

Brian Paul brianp at vmware.com
Mon Jan 28 15:38:16 PST 2013


On 01/28/2013 04:11 PM, Stéphane Marchesin wrote:
> Check that the return value from xcb_dri2_swap_buffers_reply is
> non-NULL before accessing the struct members.
> ---
>   src/glx/dri2_glx.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
> index a51716f..78a2a42 100644
> --- a/src/glx/dri2_glx.c
> +++ b/src/glx/dri2_glx.c
> @@ -789,9 +789,11 @@ dri2XcbSwapBuffers(Display *dpy,
>
>      swap_buffers_reply =
>         xcb_dri2_swap_buffers_reply(c, swap_buffers_cookie, NULL);
> -   ret = merge_counter(swap_buffers_reply->swap_hi,
> -                       swap_buffers_reply->swap_lo);
> -   free(swap_buffers_reply);
> +   if (swap_buffers_reply) {
> +      ret = merge_counter(swap_buffers_reply->swap_hi,
> +                          swap_buffers_reply->swap_lo);
> +      free(swap_buffers_reply);
> +   }
>      return ret;
>   }
>

Maybe also tag this as a candidate for the 9.0 branch.

Reviewed-by: Brian Paul <brianp at vmware.com>


More information about the mesa-dev mailing list