[gnome-control-center/gnome-3-18] display: Fix possible crash on startup



commit ffe6d74041f41f7d9dcb74e89a86d30e9ff11a40
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Sep 23 13:36:20 2016 +0200

    display: Fix possible crash on startup
    
    If no items are added to the GVariantBuilder, g_variant_builder_close()
    would throw a critical, g_variant_builder_end() would throw a
    segmentation fault.
    
    As this can only happen when there are no items added to the output_ids
    hashtable, this should only happen if there are no displays known to
    libgnome-desktop (and therefore mutter).
    
    See https://bugzilla.redhat.com/show_bug.cgi?id=1280075
    
    https://bugzilla.gnome.org/show_bug.cgi?id=771875

 panels/display/cc-display-panel.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index 1d04571..7110631 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -120,12 +120,12 @@ monitor_labeler_show (CcDisplayPanel *self)
   GnomeRROutput *output;
   GVariantBuilder builder;
   gint number;
+  gboolean has_outputs;
 
   if (!priv->shell_proxy)
     return;
 
-  g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
-  g_variant_builder_open (&builder, G_VARIANT_TYPE_ARRAY);
+  has_outputs = FALSE;
 
   infos = gnome_rr_config_get_outputs (priv->current_configuration);
   for (info = infos; *info; info++)
@@ -134,6 +134,13 @@ monitor_labeler_show (CcDisplayPanel *self)
       if (number == 0)
         continue;
 
+      if (!has_outputs)
+        {
+          g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
+          g_variant_builder_open (&builder, G_VARIANT_TYPE_ARRAY);
+          has_outputs = TRUE;
+        }
+
       output = gnome_rr_screen_get_output_by_name (priv->screen,
                                                    gnome_rr_output_info_get_name (*info));
       g_variant_builder_add (&builder, "{uv}",
@@ -141,6 +148,9 @@ monitor_labeler_show (CcDisplayPanel *self)
                              g_variant_new_int32 (number));
     }
 
+  if (!has_outputs)
+    return;
+
   g_variant_builder_close (&builder);
 
   g_dbus_proxy_call (priv->shell_proxy,


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