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

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