[mutter/gnome-3-36] wayland/xdg-shell: Add parent window validation in get_popup()



commit 4839aa6e2eb905537fceba987d07dcd7491299b5
Author: Robert Mader <robert mader posteo de>
Date:   Sun Aug 16 22:54:23 2020 +0200

    wayland/xdg-shell: Add parent window validation in get_popup()
    
    Like in most similar places we can not assume to get a valid window
    when calling `meta_wayland_surface_get_window` as it e.g. might be
    unmapped already.
    
    Calling `get_popup` on an unmapped window is a client bug, thus post
    a protocol error when this happens.
    
    Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1174
    Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1293
    
    (cherry picked from commit 034c6ab9db2793ad8f8a5f04d46af174c04c9fa0)

 src/wayland/meta-wayland-xdg-shell.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/wayland/meta-wayland-xdg-shell.c b/src/wayland/meta-wayland-xdg-shell.c
index 05577d6481..242a1c4ef2 100644
--- a/src/wayland/meta-wayland-xdg-shell.c
+++ b/src/wayland/meta-wayland-xdg-shell.c
@@ -1872,6 +1872,15 @@ xdg_surface_constructor_get_popup (struct wl_client   *client,
       return;
     }
 
+  parent_window = meta_wayland_surface_get_window (parent_surface);
+  if (!parent_window)
+    {
+      wl_resource_post_error (xdg_wm_base_resource,
+                              XDG_WM_BASE_ERROR_INVALID_POPUP_PARENT,
+                              "Invalid popup parent window");
+      return;
+    }
+
   xdg_popup = META_WAYLAND_XDG_POPUP (surface->role);
 
   xdg_popup->resource = wl_resource_create (client,
@@ -1886,8 +1895,6 @@ xdg_surface_constructor_get_popup (struct wl_client   *client,
   xdg_surface = META_WAYLAND_XDG_SURFACE (xdg_popup);
   meta_wayland_xdg_surface_constructor_finalize (constructor, xdg_surface);
 
-  parent_window = meta_wayland_surface_get_window (parent_surface);
-
   xdg_positioner = wl_resource_get_user_data (positioner_resource);
   xdg_popup->setup.placement_rule =
     meta_wayland_xdg_positioner_to_placement (xdg_positioner, parent_window);


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