Blame SOURCES/0007-xwayland-Check-buffer-prior-to-attaching-it.patch

d05f4b
From 8a07b3e391bbed0b7d8f2ed37928b362eec3beee Mon Sep 17 00:00:00 2001
d05f4b
From: Olivier Fourdan <ofourdan@redhat.com>
d05f4b
Date: Mon, 29 Mar 2021 15:01:15 +0200
d05f4b
Subject: [PATCH xserver 07/27] xwayland: Check buffer prior to attaching it
d05f4b
MIME-Version: 1.0
d05f4b
Content-Type: text/plain; charset=UTF-8
d05f4b
Content-Transfer-Encoding: 8bit
d05f4b
d05f4b
If the buffer is NULL, do not even try to attach it, and risk a Wayland
d05f4b
protocol error which would be fatal to us.
d05f4b
d05f4b
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
d05f4b
Reviewed-by: Martin Peres <martin.peres@mupuf.org>
d05f4b
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
d05f4b
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
d05f4b
(cherry picked from commit 25d2f4948f0abd39e099b8ac69b7cb1dab38a10a)
d05f4b
---
d05f4b
 hw/xwayland/xwayland-cursor.c  | 11 +++++++++--
d05f4b
 hw/xwayland/xwayland-present.c |  7 ++++++-
d05f4b
 hw/xwayland/xwayland-window.c  |  5 +++++
d05f4b
 3 files changed, 20 insertions(+), 3 deletions(-)
d05f4b
d05f4b
diff --git a/hw/xwayland/xwayland-cursor.c b/hw/xwayland/xwayland-cursor.c
d05f4b
index fac8840e6..c4457cc2a 100644
d05f4b
--- a/hw/xwayland/xwayland-cursor.c
d05f4b
+++ b/hw/xwayland/xwayland-cursor.c
d05f4b
@@ -162,8 +162,15 @@ static void
d05f4b
 xwl_cursor_attach_pixmap(struct xwl_seat *xwl_seat,
d05f4b
                          struct xwl_cursor *xwl_cursor, PixmapPtr pixmap)
d05f4b
 {
d05f4b
-    wl_surface_attach(xwl_cursor->surface,
d05f4b
-                      xwl_shm_pixmap_get_wl_buffer(pixmap), 0, 0);
d05f4b
+    struct wl_buffer *buffer;
d05f4b
+
d05f4b
+    buffer = xwl_shm_pixmap_get_wl_buffer(pixmap);
d05f4b
+    if (!buffer) {
d05f4b
+        ErrorF("cursor: Error getting buffer\n");
d05f4b
+        return;
d05f4b
+    }
d05f4b
+
d05f4b
+    wl_surface_attach(xwl_cursor->surface, buffer, 0, 0);
d05f4b
     xwl_surface_damage(xwl_seat->xwl_screen, xwl_cursor->surface, 0, 0,
d05f4b
                        xwl_seat->x_cursor->bits->width,
d05f4b
                        xwl_seat->x_cursor->bits->height);
d05f4b
diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
d05f4b
index 7ba7efc11..83d67517a 100644
d05f4b
--- a/hw/xwayland/xwayland-present.c
d05f4b
+++ b/hw/xwayland/xwayland-present.c
d05f4b
@@ -443,6 +443,12 @@ xwl_present_flip(WindowPtr present_window,
d05f4b
     if (!xwl_window)
d05f4b
         return FALSE;
d05f4b
 
d05f4b
+    buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap);
d05f4b
+    if (!buffer) {
d05f4b
+        ErrorF("present: Error getting buffer\n");
d05f4b
+        return FALSE;
d05f4b
+    }
d05f4b
+
d05f4b
     damage_box = RegionExtents(damage);
d05f4b
 
d05f4b
     event = malloc(sizeof *event);
d05f4b
@@ -450,7 +456,6 @@ xwl_present_flip(WindowPtr present_window,
d05f4b
         return FALSE;
d05f4b
 
d05f4b
     pixmap->refcnt++;
d05f4b
-    buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap);
d05f4b
 
d05f4b
     event->event_id = event_id;
d05f4b
     event->xwl_present_window = xwl_present_window;
d05f4b
diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
d05f4b
index d0c7c581d..af4290ec7 100644
d05f4b
--- a/hw/xwayland/xwayland-window.c
d05f4b
+++ b/hw/xwayland/xwayland-window.c
d05f4b
@@ -805,6 +805,11 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
d05f4b
 #endif
d05f4b
         buffer = xwl_shm_pixmap_get_wl_buffer(pixmap);
d05f4b
 
d05f4b
+    if (!buffer) {
d05f4b
+        ErrorF("Error getting buffer\n");
d05f4b
+        return;
d05f4b
+    }
d05f4b
+
d05f4b
 #ifdef XWL_HAS_GLAMOR
d05f4b
     if (xwl_screen->glamor)
d05f4b
         xwl_glamor_post_damage(xwl_window, pixmap, region);
d05f4b
-- 
d05f4b
2.31.1
d05f4b