Mesa (main): egl/wayland: Error on invalid native window

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 21 12:39:21 UTC 2021


Module: Mesa
Branch: main
Commit: 0e2464d26bace803aad575c117686412be82388a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0e2464d26bace803aad575c117686412be82388a

Author: Daniel Stone <daniels at collabora.com>
Date:   Tue Jul 20 13:40:00 2021 +0100

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 at collabora.com>
Reviewed-by: Simon Ser <contact at 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>

---

 src/egl/drivers/dri2/platform_wayland.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

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");



More information about the mesa-commit mailing list