Blame SOURCES/0001-wayland-Nullify-monitor-resources-when-updating-outp.patch

776610
From f45af3315d4f11e16fc998322e4b407437259ce1 Mon Sep 17 00:00:00 2001
776610
From: Olivier Fourdan <ofourdan@redhat.com>
776610
Date: Fri, 27 Jul 2018 16:32:31 +0000
776610
Subject: [PATCH] wayland: Nullify monitor resources when updating outputs
776610
776610
If a client asks for xdg-output before we have set the output's logical
776610
monitor, we would end up crashing with a NULL pointer dereference.
776610
776610
Make sure we clear the resource's user data when marking an output as
776610
inert on monitor change so that we don't end up with a Wayland output
776610
without a logical monitor.
776610
776610
Closes: https://gitlab.gnome.org/GNOME/mutter/issues/194
776610
776610
776610
(cherry picked from commit 48eaa36d41bb88d4831e40e9c3ef3c7afda195bc)
776610
---
776610
 src/wayland/meta-wayland-outputs.c | 52 ++++++++++++++++++------------
776610
 1 file changed, 31 insertions(+), 21 deletions(-)
776610
776610
diff --git a/src/wayland/meta-wayland-outputs.c b/src/wayland/meta-wayland-outputs.c
776610
index 509527d38..bc67b90be 100644
776610
--- a/src/wayland/meta-wayland-outputs.c
776610
+++ b/src/wayland/meta-wayland-outputs.c
776610
@@ -365,12 +365,38 @@ meta_wayland_output_new (MetaWaylandCompositor *compositor,
776610
 }
776610
 
776610
 static void
776610
-nullify_logical_monitor (gpointer key,
776610
-                         gpointer value,
776610
-                         gpointer data)
776610
+make_output_resources_inert (MetaWaylandOutput *wayland_output)
776610
+{
776610
+  GList *l;
776610
+
776610
+  for (l = wayland_output->resources; l; l = l->next)
776610
+    {
776610
+      struct wl_resource *output_resource = l->data;
776610
+
776610
+      wl_resource_set_user_data (output_resource, NULL);
776610
+    }
776610
+  g_list_free (wayland_output->resources);
776610
+  wayland_output->resources = NULL;
776610
+
776610
+  for (l = wayland_output->xdg_output_resources; l; l = l->next)
776610
+    {
776610
+      struct wl_resource *xdg_output_resource = l->data;
776610
+
776610
+      wl_resource_set_user_data (xdg_output_resource, NULL);
776610
+    }
776610
+  g_list_free (wayland_output->xdg_output_resources);
776610
+  wayland_output->xdg_output_resources = NULL;
776610
+}
776610
+
776610
+static void
776610
+make_output_inert (gpointer key,
776610
+                   gpointer value,
776610
+                   gpointer data)
776610
 {
776610
   MetaWaylandOutput *wayland_output = value;
776610
+
776610
   wayland_output->logical_monitor = NULL;
776610
+  make_output_resources_inert (wayland_output);
776610
 }
776610
 
776610
 static gboolean
776610
@@ -420,7 +446,7 @@ meta_wayland_compositor_update_outputs (MetaWaylandCompositor *compositor,
776610
                            wayland_output);
776610
     }
776610
 
776610
-  g_hash_table_foreach (compositor->outputs, nullify_logical_monitor, NULL);
776610
+  g_hash_table_foreach (compositor->outputs, make_output_inert, NULL);
776610
   g_timeout_add_seconds (10, delayed_destroy_outputs, compositor->outputs);
776610
 
776610
   return new_table;
776610
@@ -449,23 +475,7 @@ meta_wayland_output_finalize (GObject *object)
776610
   /* Make sure the wl_output destructor doesn't try to access MetaWaylandOutput
776610
    * after we have freed it.
776610
    */
776610
-  for (l = wayland_output->resources; l; l = l->next)
776610
-    {
776610
-      struct wl_resource *output_resource = l->data;
776610
-
776610
-      wl_resource_set_user_data (output_resource, NULL);
776610
-    }
776610
-
776610
-  g_list_free (wayland_output->resources);
776610
-
776610
-  for (l = wayland_output->xdg_output_resources; l; l = l->next)
776610
-    {
776610
-      struct wl_resource *xdg_output_resource = l->data;
776610
-
776610
-      wl_resource_set_user_data (xdg_output_resource, NULL);
776610
-    }
776610
-
776610
-  g_list_free (wayland_output->xdg_output_resources);
776610
+  make_output_resources_inert (wayland_output);
776610
 
776610
   G_OBJECT_CLASS (meta_wayland_output_parent_class)->finalize (object);
776610
 }
776610
-- 
776610
2.19.0
776610