[gnome-disk-utility/gnome-3-26] Fix SIGSEGV in gdu_utils_get_all_contained_objects



commit af6df4c530820a86665d1fa67c6c9d348b3f2fbc
Author: Kai Lüke <kailueke riseup net>
Date:   Mon Sep 4 10:00:07 2017 +0900

    Fix SIGSEGV in gdu_utils_get_all_contained_objects
    
    The variable block_object was used as argument without
    testing whether it is NULL.
    
    The depending code after assignment is now guarded with
    a if-block.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=787230

 src/libgdu/gduutils.c |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)
---
diff --git a/src/libgdu/gduutils.c b/src/libgdu/gduutils.c
index 76520ba..8543567 100644
--- a/src/libgdu/gduutils.c
+++ b/src/libgdu/gduutils.c
@@ -1173,21 +1173,24 @@ gdu_utils_get_all_contained_objects (UDisksClient *client,
   if (block != NULL)
     {
       block_object = (UDisksObject *) g_dbus_interface_dup_object (G_DBUS_INTERFACE (block));
-      objects_to_check = g_list_prepend (objects_to_check, g_object_ref (block_object));
-    }
-
-  /* if we're a partitioned block device, add all partitions */
-  partition_table = udisks_object_get_partition_table (block_object);
-  if (partition_table != NULL)
-    {
-      partitions = udisks_client_get_partitions (client, partition_table);
-      for (l = partitions; l != NULL; l = l->next)
+      if (block_object != NULL)
         {
-          UDisksPartition *partition = UDISKS_PARTITION (l->data);
-          UDisksObject *partition_object;
-          partition_object = (UDisksObject *) g_dbus_interface_dup_object (G_DBUS_INTERFACE (partition));
-          if (partition_object != NULL)
-            objects_to_check = g_list_append (objects_to_check, partition_object);
+          objects_to_check = g_list_prepend (objects_to_check, g_object_ref (block_object));
+
+          /* if we're a partitioned block device, add all partitions */
+          partition_table = udisks_object_get_partition_table (block_object);
+          if (partition_table != NULL)
+            {
+              partitions = udisks_client_get_partitions (client, partition_table);
+              for (l = partitions; l != NULL; l = l->next)
+                {
+                  UDisksPartition *partition = UDISKS_PARTITION (l->data);
+                  UDisksObject *partition_object;
+                  partition_object = (UDisksObject *) g_dbus_interface_dup_object (G_DBUS_INTERFACE 
(partition));
+                  if (partition_object != NULL)
+                    objects_to_check = g_list_append (objects_to_check, partition_object);
+                }
+            }
         }
     }
 


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