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;