[PATCH weston] compositor: fix memory corruption when removing an output

Giulio Camuffo giuliocamuffo at gmail.com
Sat Sep 6 06:18:02 PDT 2014


The destructor set on the wl_output resources needs the weston_output
to be allocated, because it removes the resource from its list.
So unset the destructor on all the resources when destroying an
output.
---
 src/compositor.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/compositor.c b/src/compositor.c
index 20ff6b2..e9c8a49 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3248,6 +3248,8 @@ weston_compositor_remove_output(struct weston_compositor *compositor,
 WL_EXPORT void
 weston_output_destroy(struct weston_output *output)
 {
+	struct wl_resource *resource;
+
 	output->destroying = 1;
 
 	weston_compositor_remove_output(output->compositor, output);
@@ -3261,6 +3263,10 @@ weston_output_destroy(struct weston_output *output)
 	pixman_region32_fini(&output->previous_damage);
 	output->compositor->output_id_pool &= ~(1 << output->id);
 
+	wl_resource_for_each(resource, &output->resource_list) {
+		wl_resource_set_destructor(resource, NULL);
+	}
+
 	wl_global_destroy(output->global);
 }
 
-- 
2.1.0



More information about the wayland-devel mailing list