[mutter/gnome-3-36] wayland/xdg-shell: Handle null-parent in get_popup()



commit d37e728bbd189513adbce1fa0889ef37b2efe6cc
Author: Robert Mader <robert mader posteo de>
Date:   Wed Aug 26 20:51:13 2020 +0200

    wayland/xdg-shell: Handle null-parent in get_popup()
    
    The spec allows `parent_resource` to be `NULL`, requiring the parent
    surface to get specified by some other protocol. Send a protocol error
    with some meaningful explanation instead of crashing.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1408
    
    (cherry picked from commit 88ff196fe3ca5a83f2cb57193c84f331f6a8ad66)

 src/wayland/meta-wayland-xdg-shell.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/wayland/meta-wayland-xdg-shell.c b/src/wayland/meta-wayland-xdg-shell.c
index 242a1c4ef2..df4d6f1185 100644
--- a/src/wayland/meta-wayland-xdg-shell.c
+++ b/src/wayland/meta-wayland-xdg-shell.c
@@ -1845,8 +1845,7 @@ xdg_surface_constructor_get_popup (struct wl_client   *client,
   MetaWaylandSurface *surface = constructor->surface;
   struct wl_resource *xdg_wm_base_resource = constructor->shell_client->resource;
   struct wl_resource *xdg_surface_resource = constructor->resource;
-  MetaWaylandSurface *parent_surface =
-    surface_from_xdg_surface_resource (parent_resource);
+  MetaWaylandSurface *parent_surface;
   MetaWindow *parent_window;
   MetaWaylandXdgPositioner *xdg_positioner;
   MetaWaylandXdgPopup *xdg_popup;
@@ -1864,6 +1863,16 @@ xdg_surface_constructor_get_popup (struct wl_client   *client,
       return;
     }
 
+  if (!parent_resource)
+    {
+      wl_resource_post_error (xdg_wm_base_resource,
+                              XDG_WM_BASE_ERROR_INVALID_POPUP_PARENT,
+                              "Parent surface is null but Mutter does not yet "
+                              "support specifying parent surfaces via other "
+                              "protocols");
+    }
+
+  parent_surface = surface_from_xdg_surface_resource (parent_resource);
   if (!META_IS_WAYLAND_XDG_SURFACE (parent_surface->role))
     {
       wl_resource_post_error (xdg_wm_base_resource,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]