diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index 9ffd67ab58c..5ffdf132184 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -1211,7 +1211,10 @@ dri2_find_screen_for_display(const _EGLDisplay *disp, int fallback_screen) { const EGLAttrib *attr; - for (attr = disp->Options.Attribs; attr; attr += 2) { + if (!disp->Options.Attribs) + return fallback_screen; + + for (attr = disp->Options.Attribs; attr[0] != EGL_NONE; attr += 2) { if (attr[0] == EGL_PLATFORM_X11_SCREEN_EXT || attr[0] == EGL_PLATFORM_XCB_SCREEN_EXT) return attr[1];