[mutter] wayland: Protect against unordered destruction of surface resources



commit 3ff63165621eef9ca900d7fcde2c25ee194d6a95
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Mar 10 13:42:01 2015 +0100

    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

 src/wayland/meta-wayland-surface.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index c62e8eb..5dfa8fb 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]