[mutter] wayland: do not leak shortcut inhibit data



commit 2bf7974076ea99c9b30fe5b3d49456dba5a20c19
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Tue Sep 12 10:27:32 2017 +0200

    wayland: do not leak shortcut inhibit data
    
    We would free the shortcut inhibit data only when the client destroys
    its request, which is not the case when the clients itself is
    destroyed, leading to a leak of the shortcut inhibit data.
    
    Free the data on resource destruction instead, and simply destroy the
    resource on destroy request.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=787568

 src/wayland/meta-wayland-inhibit-shortcuts.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/wayland/meta-wayland-inhibit-shortcuts.c b/src/wayland/meta-wayland-inhibit-shortcuts.c
index a7ba3c2..8e5ed24 100644
--- a/src/wayland/meta-wayland-inhibit-shortcuts.c
+++ b/src/wayland/meta-wayland-inhibit-shortcuts.c
@@ -41,8 +41,7 @@ struct _MetaWaylandKeyboardShotscutsInhibit
 };
 
 static void
-zwp_keyboard_shortcuts_inhibit_destroy (struct wl_client   *client,
-                                        struct wl_resource *resource)
+zwp_keyboard_shortcuts_inhibit_destructor (struct wl_resource *resource)
 {
   MetaWaylandKeyboardShotscutsInhibit *shortcut_inhibit;
 
@@ -64,6 +63,12 @@ zwp_keyboard_shortcuts_inhibit_destroy (struct wl_client   *client,
                                               shortcut_inhibit->seat);
     }
   g_free (shortcut_inhibit);
+}
+
+static void
+zwp_keyboard_shortcuts_inhibit_destroy (struct wl_client   *client,
+                                        struct wl_resource *resource)
+{
   wl_resource_destroy (resource);
 }
 
@@ -148,7 +153,7 @@ zwp_keyboard_shortcuts_inhibit_manager_inhibit_shortcuts (struct wl_client   *cl
   wl_resource_set_implementation (keyboard_shortcuts_inhibit_resource,
                                   &meta_keyboard_shortcuts_inhibit_interface,
                                   shortcut_inhibit,
-                                  NULL);
+                                  zwp_keyboard_shortcuts_inhibit_destructor);
 }
 
 static const struct zwp_keyboard_shortcuts_inhibit_manager_v1_interface


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