[gparted] Resolve empty drive displayed as blank minor logic issue (#152)



commit b3ff339ac7329a5dd7f29e56c0acb4ef840ad4d8
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sat Apr 10 17:08:07 2021 +0100

    Resolve empty drive displayed as blank minor logic issue (#152)
    
    The previous commit "Remove coding landmine in get_disk() (#152)" made
    an empty drive without a disk label (partition table) display as
    nothing, instead of the normal single unallocated partition with warning
    "unrecognised disk label".
    
    The previous commit said:
        3. The two remaining direct calls to get_disk() where the strict
           parameter is explicitly set to false, from set_device_from_disk()
           and detect_filesystem_in_encryption_mapping(), are when scanning.
           As the pass strict=false they don't allow the PedDevice deletion
           to occur if no recognised disk label is found.
    
    This is true, but get_disk(..., strict=false) additionally returned true
    even if there was no disk label.  And in set_device_from_disk() the
    empty drive case is inside the if branch of the get_disk() call
    returning true.
    
    Simply fix this by calling get_disk(), ignoring the return value.
    
    Closes #152 - GParted crashed when trying to probe an encrypted
                  partition containing content that libparted doesn't
                  recognise

 src/GParted_Core.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index b6a45644..b3ee68bf 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -687,8 +687,10 @@ void GParted_Core::set_device_from_disk( Device & device, const Glib::ustring &
                        set_device_one_partition( device, lp_device, fstype, messages );
                }
                // Partitioned drive
-               else if (get_disk(lp_device, lp_disk))
+               else
                {
+                       get_disk(lp_device, lp_disk);
+
                        // Partitioned drive (excluding "loop"), as recognised by libparted
                        if ( lp_disk && lp_disk->type && lp_disk->type->name &&
                             strcmp( lp_disk->type->name, "loop" ) != 0         )


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