From b111e8aa4940e8b155f38b5ef238c295ded8a6b4 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Mon, 2 Jan 2023 17:27:41 +0100 Subject: [PATCH] egl: handle NULL loaderPrivate in dri_is_thread_safe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This can happen when a context is created from loader_dri3_blit_context_get and glthread is enabled. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7949 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7960 Cc: mesa-stable Acked-by: Eric Engestrom Reviewed-by: Marek Olšák Part-of: --- src/egl/drivers/dri2/egl_dri2.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 239dc6d9f17..6fbb001964d 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -160,12 +160,20 @@ dri2_gl_flush() } static GLboolean -dri_is_thread_safe(void *loaderPrivate) +dri_is_thread_safe(UNUSED void *loaderPrivate) { - struct dri2_egl_surface *dri2_surf = loaderPrivate; - UNUSED _EGLDisplay *display = dri2_surf->base.Resource.Display; - #ifdef HAVE_X11_PLATFORM + struct dri2_egl_surface *dri2_surf = loaderPrivate; + + /* loader_dri3_blit_context_get creates a context with + * loaderPrivate being NULL. Enabling glthread for a blitting + * context isn't useful so return false. + */ + if (!loaderPrivate) + return false; + + _EGLDisplay *display = dri2_surf->base.Resource.Display; + Display *xdpy = (Display*)display->PlatformDisplay; /* Check Xlib is running in thread safe mode when running on EGL/X11-xlib