[mutter/cherry-pick-7b83735a] wayland/output: Always set xdg_output interface implementation




commit 1f92bd1aebb671620239c398dd8ab96fe1d28116
Author: Jonas Ådahl <jadahl gmail com>
Date:   Thu Dec 2 19:02:33 2021 +0100

    wayland/output: Always set xdg_output interface implementation
    
    This avoids the following crash, that could happen in certain rare race
    conditions, e.g. in tests:
    
      0) wl_closure_invoke (closure=0x2fbf9e0, target=0x2e5b3d0, opcode=0)
         at ../src/connection.c:1014
      1) wl_client_connection_data () at ../src/wayland-server.c:432
      2) wl_event_loop_dispatch () at ../src/event-loop.c:1027
      3) wayland_event_source_dispatch () at ../src/wayland/meta-wayland.c:104
      4) g_main_dispatch () at ../glib/gmain.c:3381
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2127>
    
    
    (cherry picked from commit 7b83735aeac48514e55749e6629003b237919d23)

 src/wayland/meta-wayland-outputs.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/wayland/meta-wayland-outputs.c b/src/wayland/meta-wayland-outputs.c
index f8069b6929..4d07c87f78 100644
--- a/src/wayland/meta-wayland-outputs.c
+++ b/src/wayland/meta-wayland-outputs.c
@@ -645,24 +645,25 @@ meta_xdg_output_manager_get_xdg_output (struct wl_client   *client,
                                             id);
 
   wayland_output = wl_resource_get_user_data (output);
-  if (!wayland_output)
-    return;
-
   wl_resource_set_implementation (xdg_output_resource,
                                   &meta_xdg_output_interface,
                                   wayland_output, meta_xdg_output_destructor);
 
+  if (!wayland_output)
+    goto done;
+
   wayland_output->xdg_output_resources =
     g_list_prepend (wayland_output->xdg_output_resources, xdg_output_resource);
 
   if (!wayland_output->monitor)
-    return;
+    goto done;
 
   send_xdg_output_events (xdg_output_resource,
                           wayland_output,
                           wayland_output->monitor,
                           TRUE, NULL);
 
+done:
   xdg_output_version = wl_resource_get_version (xdg_output_resource);
   wl_output_version = wl_resource_get_version (output);
 


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