diff --git a/src/udiskslinuxmanager.c b/src/udiskslinuxmanager.c index 5bfeec103..8bb81c873 100644 --- a/src/udiskslinuxmanager.c +++ b/src/udiskslinuxmanager.c @@ -1192,12 +1192,16 @@ handle_get_block_devices (UDisksManager *object, const gchar **block_paths = NULL; guint num_blocks = 0; guint i = 0; + GDBusObject *block_object = NULL; blocks = get_block_objects (object, &num_blocks); block_paths = g_new0 (const gchar *, num_blocks + 1); - for (i = 0,blocks_p = blocks; blocks_p != NULL; blocks_p = blocks_p->next, i++) - block_paths[i] = g_dbus_object_get_object_path (g_dbus_interface_get_object (G_DBUS_INTERFACE (blocks_p->data))); + for (blocks_p = blocks; blocks_p != NULL; blocks_p = blocks_p->next) { + block_object = g_dbus_interface_get_object (G_DBUS_INTERFACE (blocks_p->data)); + if (block_object) + block_paths[i++] = g_dbus_object_get_object_path (block_object); + } udisks_manager_complete_get_block_devices (object, invocation,