[mutter/wip/carlosg/unlink-listeners: 28/28] wayland: Ensure to remove destroy listener for MetaWaylandBuffer




commit 9c402bd091255e8a21f7e3263559dbe63135dec7
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Aug 19 17:13:01 2022 +0200

    wayland: Ensure to remove destroy listener for MetaWaylandBuffer
    
    Avoid the chance of invalid memory access by leaving the wl_listener
    behind when handling the destroy notification.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2588>

 src/wayland/meta-wayland-buffer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/src/wayland/meta-wayland-buffer.c b/src/wayland/meta-wayland-buffer.c
index 557952b6fe..7a22f824bc 100644
--- a/src/wayland/meta-wayland-buffer.c
+++ b/src/wayland/meta-wayland-buffer.c
@@ -83,12 +83,13 @@ G_DEFINE_TYPE (MetaWaylandBuffer, meta_wayland_buffer, G_TYPE_OBJECT);
 
 static void
 meta_wayland_buffer_destroy_handler (struct wl_listener *listener,
-                                     void *data)
+                                     void               *data)
 {
   MetaWaylandBuffer *buffer =
     wl_container_of (listener, buffer, destroy_listener);
 
   buffer->resource = NULL;
+  wl_list_remove (&buffer->destroy_listener.link);
   g_signal_emit (buffer, signals[RESOURCE_DESTROYED], 0);
   g_object_unref (buffer);
 }


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