diff options
author | Chad Versace <chad.versace@intel.com> | 2016-04-25 16:50:40 -0700 |
---|---|---|
committer | Chad Versace <chad.versace@intel.com> | 2016-04-28 10:49:30 -0700 |
commit | 8ed4a8c31d989b699659c5371854a0c596e6fad3 (patch) | |
tree | ba9393007f39740e7b8444ee882baab212c1d32a | |
parent | 1d2374f463b3b14dfae8d9993b2e7aab756077a6 (diff) |
util: Fix crash when xcb_get_setup() fails
Return early if xcb_get_setup() returns NULL. Don't use the NULL.
-rw-r--r-- | tests/util/piglit-framework-gl/piglit_drm_dma_buf.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/util/piglit-framework-gl/piglit_drm_dma_buf.c b/tests/util/piglit-framework-gl/piglit_drm_dma_buf.c index 44fd0d1f7..e286e269c 100644 --- a/tests/util/piglit-framework-gl/piglit_drm_dma_buf.c +++ b/tests/util/piglit-framework-gl/piglit_drm_dma_buf.c @@ -81,6 +81,7 @@ piglit_drm_x11_authenticate(void) drm_magic_t magic; xcb_connection_t *conn; int screen; + const xcb_setup_t *setup; xcb_screen_iterator_t screen_iter; xcb_dri2_authenticate_cookie_t auth_cookie; xcb_dri2_authenticate_reply_t *auth_reply; @@ -99,7 +100,13 @@ piglit_drm_x11_authenticate(void) return false; } - screen_iter = xcb_setup_roots_iterator(xcb_get_setup(conn)); + setup = xcb_get_setup(conn); + if (!setup) { + printf("piglit: xcb_get_setup() failed\n"); + return false; + } + + screen_iter = xcb_setup_roots_iterator(setup); auth_cookie = xcb_dri2_authenticate_unchecked(conn, screen_iter.data->root, magic); |