[Piglit] [PATCH 2/3] util: Fix crash when xcb_get_setup() fails

Chad Versace chad.versace at intel.com
Tue Apr 26 20:04:57 UTC 2016


Return early if xcb_get_setup() returns NULL. Don't use the NULL.
---
 tests/util/piglit-framework-gl/piglit_drm_dma_buf.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

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 44fd0d1..e286e26 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);
-- 
2.8.1



More information about the Piglit mailing list