From 70f290198937f76b7cf8de3ae9618d0aa5880e80 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Thu, 9 Jan 2014 15:43:17 -0800 Subject: [PATCH] shell: Make sure we still have touch or pointer focus when moving/resizing It's possible to touch a surface to move it and let go before we get to common_surface_move(), in which case we don't have a touch focus when we get there. For pointers, we could click a surface, but have the surface go away before we get to common_surface_move(), in which case the button count is non-zero, but we don't have a surface. In either case we crash, so let's add a check to make sure we still have a focus surface before we try to move it. Closes: https://bugs.freedesktop.org/show_bug.cgi?id=73448 --- desktop-shell/shell.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 00c7b01..c82c00f 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -1469,6 +1469,7 @@ common_surface_move(struct wl_resource *resource, struct weston_surface *surface; if (seat->pointer && + seat->pointer->focus && seat->pointer->button_count > 0 && seat->pointer->grab_serial == serial) { surface = weston_surface_get_main_surface(seat->pointer->focus->surface); @@ -1476,6 +1477,7 @@ common_surface_move(struct wl_resource *resource, (surface_move(shsurf, seat) < 0)) wl_resource_post_no_memory(resource); } else if (seat->touch && + seat->touch->focus && seat->touch->grab_serial == serial) { surface = weston_surface_get_main_surface(seat->touch->focus->surface); if ((surface == shsurf->surface) && @@ -1656,10 +1658,13 @@ common_surface_resize(struct wl_resource *resource, if (shsurf->state.fullscreen) return; - surface = weston_surface_get_main_surface(seat->pointer->focus->surface); if (seat->pointer->button_count == 0 || seat->pointer->grab_serial != serial || - surface != shsurf->surface) + seat->pointer->focus == NULL) + return; + + surface = weston_surface_get_main_surface(seat->pointer->focus->surface); + if (surface != shsurf->surface) return; if (surface_resize(shsurf, seat, edges) < 0) -- 2.7.4