From 578d3a62cad0fc07c4c22011c5a2a1d1cd24372a Mon Sep 17 00:00:00 2001 From: Orko Garai Date: Fri, 21 Mar 2025 08:12:01 -0400 Subject: [PATCH] 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: --- src/wayland/meta-wayland-pointer-constraints.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wayland/meta-wayland-pointer-constraints.c b/src/wayland/meta-wayland-pointer-constraints.c index 08f96b2ed..34a1996a1 100644 --- a/src/wayland/meta-wayland-pointer-constraints.c +++ b/src/wayland/meta-wayland-pointer-constraints.c @@ -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;