[gnome-control-center/wip/oholy/info-crashes-stable] info: Fix crashes when retrieving disk size



commit 26287234bd9152fbe95baa82b9d55b8064d789c2
Author: Ondrej Holy <oholy redhat com>
Date:   Wed Mar 13 15:49:33 2019 +0100

    info: Fix crashes when retrieving disk size
    
    Info panel crashes has been fixed by !387 on master branch, however,
    gnome-3-30 is still affected as the same fix can't be used there, because
    its complexity and changed dependencies. The panel crashes because
    GUnixMountPoint is by mistake used as GUnixMountEntry. Let's find
    and use corresponing GUnixMountEntry to simply fix those crashes for
    gnome-3-30.
    
    Closes: #411

 panels/info/cc-info-overview-panel.c | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)
---
diff --git a/panels/info/cc-info-overview-panel.c b/panels/info/cc-info-overview-panel.c
index 7758271b1..fa9510b06 100644
--- a/panels/info/cc-info-overview-panel.c
+++ b/panels/info/cc-info-overview-panel.c
@@ -546,10 +546,30 @@ get_primary_disc_info_start (CcInfoOverviewPanel *self)
                                       self);
 }
 
+static GList *
+convert_points_to_entries (GList *points)
+{
+  GList *entries = NULL;
+  GList *p;
+
+  for (p = points; p != NULL; p = p->next)
+    {
+      GUnixMountPoint *point = p->data;
+      GUnixMountEntry *mount;
+      const gchar *mount_path = g_unix_mount_point_get_mount_path (point);
+
+      mount = g_unix_mount_at (mount_path, NULL);
+      if (mount)
+        entries = g_list_append (entries, mount);
+    }
+
+  return entries;
+}
+
 static void
 get_primary_disc_info (CcInfoOverviewPanel *self)
 {
-  GList *points;
+  GList *points, *entries = NULL;
   GList *p;
   GHashTable *hash;
   CcInfoOverviewPanelPrivate *priv = cc_info_overview_panel_get_instance_private (self);
@@ -557,11 +577,14 @@ get_primary_disc_info (CcInfoOverviewPanel *self)
   hash = g_hash_table_new (g_str_hash, g_str_equal);
   points = g_unix_mount_points_get (NULL);
 
+  entries = convert_points_to_entries (points);
+  g_list_free_full (points, (GDestroyNotify) g_unix_mount_point_free);
+
   /* If we do not have /etc/fstab around, try /etc/mtab */
-  if (points == NULL)
-    points = g_unix_mounts_get (NULL);
+  if (entries == NULL)
+    entries = g_unix_mounts_get (NULL);
 
-  for (p = points; p != NULL; p = p->next)
+  for (p = entries; p != NULL; p = p->next)
     {
       GUnixMountEntry *mount = p->data;
       const char *mount_path;
@@ -586,7 +609,7 @@ get_primary_disc_info (CcInfoOverviewPanel *self)
       priv->primary_mounts = g_list_prepend (priv->primary_mounts, mount);
       g_hash_table_insert (hash, (gpointer) device_path, (gpointer) device_path);
     }
-  g_list_free (points);
+  g_list_free (entries);
   g_hash_table_destroy (hash);
 
   priv->cancellable = g_cancellable_new ();


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