[PATCH] compositor: fix dangling pointer

Pavel Sterin codeatstake at googlemail.com
Tue Feb 14 14:00:03 PST 2012


if a client crashes during drag and drop a notify_motion
can be triggered after the surface has been destroyed, so traverse
all the input devices and look reset the corresponding grab
focus.
---
 src/compositor.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index ab90ded..b3e61eb 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -602,6 +602,12 @@ destroy_surface(struct wl_resource *resource)
 			     struct weston_surface, surface.resource);
 	struct weston_compositor *compositor = surface->compositor;
 
+	wl_list_for_each(device, &compositor->input_device_list, link) {
+		if (device->input_device.grab->focus == (struct wl_surface *) surface) {
+			device->input_device.grab->focus = NULL;
+		}
+	}
+
 	if (surface->output) {
 		weston_surface_damage_below(surface);
 		weston_surface_flush_damage(surface);
-- 
1.7.7.6



More information about the wayland-devel mailing list