diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index 4895e6d24fd..f573f99ac8b 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -1765,7 +1765,7 @@ check_xshm(struct dri2_egl_display *dri2_dpy) shm_cookie = xcb_query_extension(dri2_dpy->conn, 7, "MIT-SHM"); shm_reply = xcb_query_extension_reply(dri2_dpy->conn, shm_cookie, NULL); - has_mit_shm = shm_reply->present; + has_mit_shm = shm_reply && shm_reply->present; free(shm_reply); if (!has_mit_shm) return false; diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index b5ba0cdd4fc..c567cd6bc19 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -572,16 +572,21 @@ check_xshm(Display *dpy) int ret = True; xcb_query_extension_cookie_t shm_cookie; xcb_query_extension_reply_t *shm_reply; - bool has_mit_shm; shm_cookie = xcb_query_extension(c, 7, "MIT-SHM"); shm_reply = xcb_query_extension_reply(c, shm_cookie, NULL); - xshm_opcode = shm_reply->major_opcode; - has_mit_shm = shm_reply->present; - free(shm_reply); - if (!has_mit_shm) - return False; + if (shm_reply) { + bool has_mit_shm = shm_reply->present; + + if (has_mit_shm) + xshm_opcode = shm_reply->major_opcode; + + free(shm_reply); + + if (!has_mit_shm) + return False; + } cookie = xcb_shm_detach_checked(c, 0); if ((error = xcb_request_check(c, cookie))) {