Blame SOURCES/0006-xwayland-eglstream-Check-buffer-creation.patch

4c4b8b
From 95224f0f92bc516983038a6326fba041cdef6e75 Mon Sep 17 00:00:00 2001
4c4b8b
From: Olivier Fourdan <ofourdan@redhat.com>
4c4b8b
Date: Mon, 29 Mar 2021 14:22:56 +0200
4c4b8b
Subject: [PATCH xserver 06/27] xwayland/eglstream: Check buffer creation
4c4b8b
MIME-Version: 1.0
4c4b8b
Content-Type: text/plain; charset=UTF-8
4c4b8b
Content-Transfer-Encoding: 8bit
4c4b8b
4c4b8b
EGLStream wl_eglstream_display_create_stream() may fail, yet Xwayland
4c4b8b
would try to attach the buffer which may cause a fatal Wayland protocol
4c4b8b
error raised by the compositor.
4c4b8b
4c4b8b
Check if the buffer creation worked, and fail gracefully otherwise (like
4c4b8b
wayland-eglsurface does).
4c4b8b
4c4b8b
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
4c4b8b
Reviewed-by: Martin Peres <martin.peres@mupuf.org>
4c4b8b
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
4c4b8b
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
4c4b8b
(cherry picked from commit 4f0889e98306d30a37aba0fadb1fd3790c13205a)
4c4b8b
---
4c4b8b
 hw/xwayland/xwayland-glamor-eglstream.c | 8 +++++++-
4c4b8b
 1 file changed, 7 insertions(+), 1 deletion(-)
4c4b8b
4c4b8b
diff --git a/hw/xwayland/xwayland-glamor-eglstream.c b/hw/xwayland/xwayland-glamor-eglstream.c
4c4b8b
index 17295f3bd..c6e17bf8b 100644
4c4b8b
--- a/hw/xwayland/xwayland-glamor-eglstream.c
4c4b8b
+++ b/hw/xwayland/xwayland-glamor-eglstream.c
4c4b8b
@@ -548,6 +548,10 @@ xwl_eglstream_create_pending_stream(struct xwl_screen *xwl_screen,
4c4b8b
                                            stream_fd,
4c4b8b
                                            WL_EGLSTREAM_HANDLE_TYPE_FD,
4c4b8b
                                            &stream_attribs);
4c4b8b
+    if (!xwl_pixmap->buffer) {
4c4b8b
+        ErrorF("eglstream: Failed to create buffer\n");
4c4b8b
+        goto fail;
4c4b8b
+    }
4c4b8b
 
4c4b8b
     wl_buffer_add_listener(xwl_pixmap->buffer,
4c4b8b
                            &xwl_eglstream_buffer_release_listener,
4c4b8b
@@ -562,7 +566,9 @@ xwl_eglstream_create_pending_stream(struct xwl_screen *xwl_screen,
4c4b8b
 
4c4b8b
     xwl_eglstream_queue_pending_stream(xwl_screen, window, pixmap);
4c4b8b
 
4c4b8b
-    close(stream_fd);
4c4b8b
+fail:
4c4b8b
+    if (stream_fd >= 0)
4c4b8b
+        close(stream_fd);
4c4b8b
 }
4c4b8b
 
4c4b8b
 static Bool
4c4b8b
-- 
4c4b8b
2.31.1
4c4b8b