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

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