[PATCH weston] desktop-shell: destroy shell client surfaces in handle_shell_client_destroy

Derek Foreman derekf at osg.samsung.com
Tue May 26 12:24:37 PDT 2015


This prevents a use after free when the surfaces are automatically cleaned
up later, as shell_client's entry was still in the surface list.

Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---

I'm not really well versed in this, so would appreciate extra critical
review here, as this trivial patch may be trivially wrong. :)

This stops a use after free (as detected by valgrind) when closing, for
example, weston-terminal.

 desktop-shell/shell.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index fe620cb..b1bba44 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -5817,11 +5817,16 @@ launch_desktop_shell_process(void *data)
 static void
 handle_shell_client_destroy(struct wl_listener *listener, void *data)
 {
+	struct wl_resource *shsurf_resource, *next;
 	struct shell_client *sc =
 		container_of(listener, struct shell_client, destroy_listener);
 
 	if (sc->ping_timer)
 		wl_event_source_remove(sc->ping_timer);
+
+	wl_resource_for_each_safe(shsurf_resource, next, &sc->surface_list)
+		wl_resource_destroy(shsurf_resource);
+
 	free(sc);
 }
 
-- 
2.1.4



More information about the wayland-devel mailing list