Add exception handle for multithread case.
[platform/upstream/mesa.git] / src / egl / drivers / dri2 / egl_dri2.c
index df2a13f..d04ed54 100644 (file)
@@ -826,6 +826,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;