egl/wayland: Error on invalid native window

We unconditionally require a wl_egl_window to be passed as the native
window type, and do not permit a default window. The spec requires us to
return EGL_BAD_NATIVE_WINDOW when doing this, rather than crashing.

Further, if an EGLSurface has already been created for an existing
native window, we are required to return EGL_BAD_ALLOC.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2251
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4902
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11979>
(cherry picked from commit 0e2464d26b)
This commit is contained in:
Daniel Stone 2021-07-20 13:40:00 +01:00 committed by Dylan Baker
parent ba9e463c65
commit 8447b1d52b
2 changed files with 11 additions and 1 deletions

View file

@ -121,7 +121,7 @@
"description": "egl/wayland: Error on invalid native window",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -311,6 +311,16 @@ dri2_wl_create_window_surface(_EGLDisplay *disp, _EGLConfig *conf,
int visual_idx;
const __DRIconfig *config;
if (!window) {
_eglError(EGL_BAD_NATIVE_WINDOW, "dri2_create_surface");
return NULL;
}
if (window->driver_private) {
_eglError(EGL_BAD_ALLOC, "dri2_create_surface");
return NULL;
}
dri2_surf = calloc(1, sizeof *dri2_surf);
if (!dri2_surf) {
_eglError(EGL_BAD_ALLOC, "dri2_create_surface");