wayland: Protect against unordered destruction of surface resources

If the wl_surface resource happens to be destroyed before any other
role resource, the destructor for the latter will attempt to
access/modify random memory.

Fix this by ensuring the associated resources are destroyed on the
wl_surface destructor, this will free all associated memory and
remove the resources ahead of their imminent destruction.

https://bugzilla.gnome.org/show_bug.cgi?id=745734
This commit is contained in:
Carlos Garnacho 2015-03-10 13:42:01 +01:00
parent 43058a3698
commit 3ff6316562

View File

@ -684,6 +684,18 @@ wl_surface_destructor (struct wl_resource *resource)
if (surface->resource)
wl_resource_set_user_data (surface->resource, NULL);
if (surface->xdg_surface)
wl_resource_destroy (surface->xdg_surface);
if (surface->xdg_popup)
wl_resource_destroy (surface->xdg_popup);
if (surface->wl_subsurface)
wl_resource_destroy (surface->wl_subsurface);
if (surface->wl_shell_surface)
wl_resource_destroy (surface->wl_shell_surface);
if (surface->gtk_surface)
wl_resource_destroy (surface->gtk_surface);
g_slice_free (MetaWaylandSurface, surface);
meta_wayland_compositor_repick (compositor);