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

Stéphane Marchesin marcheu at chromium.org
Mon Jan 28 15:11:21 PST 2013


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;
 }
 
-- 
1.8.1



More information about the mesa-dev mailing list