From 00535ce6b4bee3daac378e3baa83966dcbd96b0b Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Sat, 6 Sep 2014 16:18:02 +0300 Subject: [PATCH] compositor: fix memory corruption when removing an output 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. Reviewed-by: Pekka Paalanen --- src/compositor.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/compositor.c b/src/compositor.c index c9871cb5..18975bf4 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); }