wayland/pointer-gestures: Fix crash in get_*_gesture after pointer is destroyed

Properly handle cases where the pointer object has already been
destroyed to prevent the compositor from crashing with a null pointer
dereference when a client invokes a get_*_gesture method after the
pointer object is destroyed e.g. when the current login session is not on
foreground.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2237
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2690>
This commit is contained in:
msizanoen1 2022-11-06 11:38:22 +07:00 committed by Marge Bot
parent db1000e264
commit 992e169d84
3 changed files with 27 additions and 15 deletions

View File

@ -139,15 +139,19 @@ meta_wayland_pointer_gesture_hold_create_new_resource (MetaWaylandPointer *point
MetaWaylandPointerClient *pointer_client;
struct wl_resource *res;
pointer_client = meta_wayland_pointer_get_pointer_client (pointer, client);
g_return_if_fail (pointer_client != NULL);
res = wl_resource_create (client, &zwp_pointer_gesture_hold_v1_interface,
wl_resource_get_version (pointer_resource), id);
wl_resource_set_implementation (res, &pointer_gesture_hold_interface, pointer,
meta_wayland_pointer_unbind_pointer_client_resource);
wl_list_insert (&pointer_client->hold_gesture_resources,
wl_resource_get_link (res));
if (pointer)
{
pointer_client = meta_wayland_pointer_get_pointer_client (pointer, client);
g_return_if_fail (pointer_client != NULL);
wl_list_insert (&pointer_client->hold_gesture_resources,
wl_resource_get_link (res));
}
}
void

View File

@ -170,15 +170,19 @@ meta_wayland_pointer_gesture_pinch_create_new_resource (MetaWaylandPointer *poin
MetaWaylandPointerClient *pointer_client;
struct wl_resource *res;
pointer_client = meta_wayland_pointer_get_pointer_client (pointer, client);
g_return_if_fail (pointer_client != NULL);
res = wl_resource_create (client, &zwp_pointer_gesture_pinch_v1_interface,
wl_resource_get_version (gestures_resource), id);
wl_resource_set_implementation (res, &pointer_gesture_pinch_interface, pointer,
meta_wayland_pointer_unbind_pointer_client_resource);
wl_list_insert (&pointer_client->pinch_gesture_resources,
wl_resource_get_link (res));
if (pointer)
{
pointer_client = meta_wayland_pointer_get_pointer_client (pointer, client);
g_return_if_fail (pointer_client != NULL);
wl_list_insert (&pointer_client->pinch_gesture_resources,
wl_resource_get_link (res));
}
}
void

View File

@ -166,15 +166,19 @@ meta_wayland_pointer_gesture_swipe_create_new_resource (MetaWaylandPointer *poin
MetaWaylandPointerClient *pointer_client;
struct wl_resource *res;
pointer_client = meta_wayland_pointer_get_pointer_client (pointer, client);
g_return_if_fail (pointer_client != NULL);
res = wl_resource_create (client, &zwp_pointer_gesture_swipe_v1_interface,
wl_resource_get_version (pointer_resource), id);
wl_resource_set_implementation (res, &pointer_gesture_swipe_interface, pointer,
meta_wayland_pointer_unbind_pointer_client_resource);
wl_list_insert (&pointer_client->swipe_gesture_resources,
wl_resource_get_link (res));
if (pointer)
{
pointer_client = meta_wayland_pointer_get_pointer_client (pointer, client);
g_return_if_fail (pointer_client != NULL);
wl_list_insert (&pointer_client->swipe_gesture_resources,
wl_resource_get_link (res));
}
}
void