glx: Check that swap_buffers_reply is non-NULL before using it
authorStéphane Marchesin <marcheu@chromium.org>
Mon, 28 Jan 2013 23:04:00 +0000 (15:04 -0800)
committerStéphane Marchesin <marcheu@chromium.org>
Tue, 29 Jan 2013 19:15:22 +0000 (11:15 -0800)
Check that the return value from xcb_dri2_swap_buffers_reply is
non-NULL before accessing the struct members.

Note: This is a candidate for the 9.0 branch.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/glx/dri2_glx.c

index a51716fedb9663daf0581c1d40738389b94f3eed..78a2a42ddab223502f00643d51293ac29092ac1f 100644 (file)
@@ -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;
 }