[mutter/gnome-3-38] wayland/subsurface: Check for circular relationships
- From: Robert Mader <rmader src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gnome-3-38] wayland/subsurface: Check for circular relationships
- Date: Thu, 5 Nov 2020 21:21:50 +0000 (UTC)
commit a0a4c3e52a0d3db7c7d43abc535326cac4760b24
Author: Robert Mader <robert mader posteo de>
Date: Wed Nov 4 19:32:21 2020 +0100
wayland/subsurface: Check for circular relationships
If a subsurface is equal to or an ancestor of the parent surface
we currently crash. Check for that case and terminate the client.
Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1521
(cherry picked from commit 4e9a67acc6e09b012b6034b1928c2cc6ba0cb1bf)
src/wayland/meta-wayland-subsurface.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
---
diff --git a/src/wayland/meta-wayland-subsurface.c b/src/wayland/meta-wayland-subsurface.c
index bf14e0e3c9..5df3e58154 100644
--- a/src/wayland/meta-wayland-subsurface.c
+++ b/src/wayland/meta-wayland-subsurface.c
@@ -530,6 +530,17 @@ surface_handle_parent_surface_destroyed (struct wl_listener *listener,
surface->sub.parent = NULL;
}
+static gboolean
+is_same_or_ancestor (MetaWaylandSurface *surface,
+ MetaWaylandSurface *other_surface)
+{
+ if (surface == other_surface)
+ return TRUE;
+ if (other_surface->sub.parent)
+ return is_same_or_ancestor (surface, other_surface->sub.parent);
+ return FALSE;
+}
+
static void
wl_subcompositor_get_subsurface (struct wl_client *client,
struct wl_resource *resource,
@@ -549,6 +560,16 @@ wl_subcompositor_get_subsurface (struct wl_client *client,
return;
}
+ if (is_same_or_ancestor (surface, parent))
+ {
+ wl_resource_post_error (resource, WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE,
+ "Circular relationship between wl_surface@%d "
+ "and parent surface wl_surface@%d",
+ wl_resource_get_id (surface->resource),
+ wl_resource_get_id (parent->resource));
+ return;
+ }
+
if (!meta_wayland_surface_assign_role (surface,
META_TYPE_WAYLAND_SUBSURFACE,
NULL))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]