From 8447b1d52b73febefcd1fcecee1669dfc20a4369 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 20 Jul 2021 13:40:00 +0100 Subject: [PATCH] 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 Reviewed-by: Simon Ser Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2251 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4902 Cc: mesa-stable Part-of: (cherry picked from commit 0e2464d26bace803aad575c117686412be82388a) --- .pick_status.json | 2 +- src/egl/drivers/dri2/platform_wayland.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index f149ac84b39..cabc6b71c20 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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 }, diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 180380b4c4c..8d78e8c7e74 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -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");