From ff13a90eea0e73ad96fcad4ce2e0e1d781465d06 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Thu, 16 Feb 2023 17:54:22 +0100 Subject: [PATCH] desktop-shell: avoid crashes when a surface disappears during resize The desktop_surface object is destroyed first so it can happen that the shsurf still exists but desktop_surface is already NULL. So expand the check to make sure the desktop_surface is still available in the resize callbacks. Signed-off-by: Michael Olbrich (cherry picked from commit 06365e602bd7599760a9a1414d12d6c26ca9c445) --- desktop-shell/shell.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index d13d12ff..e4ea90f9 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -1153,7 +1153,7 @@ resize_grab_motion(struct weston_pointer_grab *grab, weston_pointer_move(pointer, event); - if (!shsurf) + if (!shsurf || !shsurf->desktop_surface) return; weston_view_from_global_fixed(shsurf->view, @@ -1204,7 +1204,7 @@ resize_grab_button(struct weston_pointer_grab *grab, if (pointer->button_count == 0 && state == WL_POINTER_BUTTON_STATE_RELEASED) { - if (resize->base.shsurf != NULL) { + if (resize->base.shsurf && resize->base.shsurf->desktop_surface) { struct weston_desktop_surface *desktop_surface = resize->base.shsurf->desktop_surface; weston_desktop_surface_set_resizing(desktop_surface, @@ -1222,7 +1222,7 @@ resize_grab_cancel(struct weston_pointer_grab *grab) { struct weston_resize_grab *resize = (struct weston_resize_grab *) grab; - if (resize->base.shsurf != NULL) { + if (resize->base.shsurf && resize->base.shsurf->desktop_surface) { struct weston_desktop_surface *desktop_surface = resize->base.shsurf->desktop_surface; weston_desktop_surface_set_resizing(desktop_surface, false);