[PATCH weston] Destroy resources when destroying an output
Mariusz Ceier
mceier+wayland at gmail.com
Thu May 8 11:07:03 PDT 2014
Hi,
I sent similar patch in the past, and this reply from Pekka may be
still relevant:
http://lists.freedesktop.org/archives/wayland-devel/2013-December/012691.html
Mariusz Ceier
On 8 May 2014 19:38, Neil Roberts <neil at linux.intel.com> wrote:
> When an output is destroyed it now also destroys any resources that
> were pointing to it. Otherwise if the resource is destroyed after the
> output then the resource would try to remove itself from the resource
> list but the head of the resource list would no longer be valid and it
> would write to invalid memory.
>
> This was found using Valgrind. It looks like there is a similar
> problem for weston_pointer_destroy and in that case there is even a
> comment suggesting we should do something about it.
>
> https://bugs.freedesktop.org/show_bug.cgi?id=78415
> ---
> src/compositor.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/src/compositor.c b/src/compositor.c
> index cd1ca9a..4162315 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -3110,6 +3110,8 @@ weston_compositor_remove_output(struct weston_compositor *compositor,
> WL_EXPORT void
> weston_output_destroy(struct weston_output *output)
> {
> + struct wl_resource *resource, *tmp;
> +
> output->destroying = 1;
>
> weston_compositor_remove_output(output->compositor, output);
> @@ -3124,6 +3126,9 @@ weston_output_destroy(struct weston_output *output)
> output->compositor->output_id_pool &= ~(1 << output->id);
>
> wl_global_destroy(output->global);
> +
> + wl_resource_for_each_safe(resource, tmp, &output->resource_list)
> + wl_resource_destroy(resource);
> }
>
> static void
> --
> 1.9.0
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list