Fix mutter crash from should_constraint_be_enabled()

In `should_constraint_be_enabled()` calling
`meta_wayland_surface_get_window()` could return a null window when the
toplevel is reset after locking pointer.

The null check was only done inside `HAVE_XWAYLAND` ifdef, and so if
mutter is built without xwayland it could lead to a crash.

Fixes: 6e818c8c38 ("build: Allow disabling xwayland")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4351>
This commit is contained in:
Orko Garai 2025-03-21 08:12:01 -04:00 committed by Bruce Leidl
parent 095e1e50da
commit 578d3a62ca

View File

@ -467,7 +467,6 @@ should_constraint_be_enabled (MetaWaylandPointerConstraint *constraint)
MetaWindow *window;
window = meta_wayland_surface_get_window (constraint->surface);
#ifdef HAVE_XWAYLAND
if (!window)
{
/*
@ -475,13 +474,13 @@ should_constraint_be_enabled (MetaWaylandPointerConstraint *constraint)
* associate the X11 Window with the wl_surface.
* For subsurfaces the window of the ancestor might be gone already.
*/
g_warn_if_fail (
#ifdef HAVE_XWAYLAND
g_warn_if_fail (meta_wayland_surface_is_xwayland (constraint->surface) ||
META_IS_WAYLAND_SUBSURFACE (constraint->surface->role));
meta_wayland_surface_is_xwayland (constraint->surface) ||
#endif
META_IS_WAYLAND_SUBSURFACE (constraint->surface->role));
return FALSE;
}
#endif
if (window->unmanaging)
return FALSE;