summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c7
-rw-r--r--src/egl/main/egldevice.c8
2 files changed, 15 insertions, 0 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 7e272a92a64..c480abea5e6 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -804,6 +804,13 @@ dri2_load_driver_common(_EGLDisplay *disp,
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
const __DRIextension **extensions;
+ /*This exception only happen in multithread case, when _eglAtExit is *
+ *called and disp is freed in main thread. */
+ if (dri2_dpy == NULL) {
+ _eglLog(_EGL_FATAL, "DRI2: disp is freed");
+ return EGL_FALSE;
+ }
+
extensions = dri2_open_driver(disp);
if (!extensions)
return EGL_FALSE;
diff --git a/src/egl/main/egldevice.c b/src/egl/main/egldevice.c
index 4e88897e2fa..c5fdd4197b6 100644
--- a/src/egl/main/egldevice.c
+++ b/src/egl/main/egldevice.c
@@ -162,6 +162,14 @@ _eglAddDevice(int fd, bool software)
mtx_lock(_eglGlobal.Mutex);
dev = _eglGlobal.DeviceList;
+ /*This exception only happen in multithread case, when _eglAtExit is *
+ *called and _eglFiniDevice(where _eglGlobal.DeviceList is set to null)*
+ *is called in main thread. */
+ if (dev == NULL) {
+ _eglLog(_EGL_FATAL, "_eglGlobal.DeviceList is freed");
+ goto out;
+ }
+
/* The first device is always software */
assert(dev);
assert(_eglDeviceSupports(dev, _EGL_DEVICE_SOFTWARE));