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




commit 68bfed573e8063cd4d04d13b38fceca347f78ecd
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.

 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]