compositor: fix memory corruption when removing an output
authorGiulio Camuffo <giuliocamuffo@gmail.com>
Sat, 6 Sep 2014 13:18:02 +0000 (16:18 +0300)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Tue, 9 Sep 2014 11:00:20 +0000 (14:00 +0300)
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 <pekka.paalanen@collabora.co.uk>
src/compositor.c

index c9871cb..18975bf 100644 (file)
@@ -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);
 }