From ec3f779aa76332b4087e1bc882e83e11a073e478 Mon Sep 17 00:00:00 2001 From: Greg V Date: Thu, 8 Nov 2018 00:24:56 +0300 Subject: [PATCH] desktop-shell: fix resize grab related crash This crash was happening when *releasing* a pointer button on a window that was being resized and got destroyed during the grab. [@daniels: Cosmetic fixes; apply same fix to grab cancel.] --- desktop-shell/shell.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 809f31c8..e0ee506b 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -1654,12 +1654,16 @@ resize_grab_button(struct weston_pointer_grab *grab, struct weston_resize_grab *resize = (struct weston_resize_grab *) grab; struct weston_pointer *pointer = grab->pointer; enum wl_pointer_button_state state = state_w; - struct weston_desktop_surface *desktop_surface = - resize->base.shsurf->desktop_surface; if (pointer->button_count == 0 && state == WL_POINTER_BUTTON_STATE_RELEASED) { - weston_desktop_surface_set_resizing(desktop_surface, false); + if (resize->base.shsurf != NULL) { + struct weston_desktop_surface *desktop_surface = + resize->base.shsurf->desktop_surface; + weston_desktop_surface_set_resizing(desktop_surface, + false); + } + shell_grab_end(&resize->base); free(grab); } @@ -1669,10 +1673,13 @@ static void resize_grab_cancel(struct weston_pointer_grab *grab) { struct weston_resize_grab *resize = (struct weston_resize_grab *) grab; - struct weston_desktop_surface *desktop_surface = - resize->base.shsurf->desktop_surface; - weston_desktop_surface_set_resizing(desktop_surface, false); + if (resize->base.shsurf != NULL) { + struct weston_desktop_surface *desktop_surface = + resize->base.shsurf->desktop_surface; + weston_desktop_surface_set_resizing(desktop_surface, false); + } + shell_grab_end(&resize->base); free(grab); }