1
0
Fork 0

wayland/xdg-foreign: Fix race condition crash

We didn't always set an implementation, when the foreign toplevel wasn't
found, and when the importer tried to set the parent-child relationship,
the implementation was missing and we'd crash in wl_closure_invoke() in
libwayland-server.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2834>
This commit is contained in:
Jonas Ådahl 2023-02-10 18:03:46 +01:00 committed by Marge Bot
parent 9ff008e31b
commit 84b6913f8a
2 changed files with 18 additions and 13 deletions

View file

@ -146,6 +146,9 @@ xdg_imported_v1_set_parent_of (struct wl_client *client,
{
MetaWaylandXdgImported *imported = wl_resource_get_user_data (resource);
if (!imported)
return;
meta_wayland_xdg_imported_set_parent_of (imported, surface_resource);
}
@ -197,16 +200,17 @@ xdg_importer_v1_import (struct wl_client *client,
imported = meta_wayland_xdg_foreign_import (foreign, xdg_imported_resource,
handle,
zxdg_imported_v1_send_destroyed);
if (!imported)
{
zxdg_imported_v1_send_destroyed (xdg_imported_resource);
return;
}
wl_resource_set_implementation (xdg_imported_resource,
&meta_xdg_imported_v1_interface,
imported,
xdg_imported_v1_destructor);
if (!imported)
{
zxdg_imported_v1_send_destroyed (xdg_imported_resource);
return;
}
}
static const struct zxdg_importer_v1_interface meta_xdg_importer_v1_interface = {

View file

@ -302,9 +302,6 @@ meta_wayland_xdg_imported_set_parent_of (MetaWaylandXdgImported *imported,
{
MetaWaylandSurface *surface;
if (!imported)
return;
if (surface_resource)
surface = wl_resource_get_user_data (surface_resource);
else
@ -348,6 +345,9 @@ xdg_imported_set_parent_of (struct wl_client *client,
{
MetaWaylandXdgImported *imported = wl_resource_get_user_data (resource);
if (!imported)
return;
meta_wayland_xdg_imported_set_parent_of (imported, surface_resource);
}
@ -448,16 +448,17 @@ xdg_importer_import (struct wl_client *client,
imported = meta_wayland_xdg_foreign_import (foreign, xdg_imported_resource,
handle,
zxdg_imported_v2_send_destroyed);
if (!imported)
{
zxdg_imported_v2_send_destroyed (xdg_imported_resource);
return;
}
wl_resource_set_implementation (xdg_imported_resource,
&meta_xdg_imported_interface,
imported,
xdg_imported_destructor);
if (!imported)
{
zxdg_imported_v2_send_destroyed (xdg_imported_resource);
return;
}
}
static const struct zxdg_importer_v2_interface meta_xdg_importer_interface = {