[gparted] Remove non-existent or invalid devices from those named (#756434)



commit bbf1a19cec72db9bda8a88324579dd7f70a0e9d8
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Tue Oct 13 16:02:01 2015 +0100

    Remove non-existent or invalid devices from those named (#756434)
    
    A non-existent or invalid disk device named on the command line caused
    two libparted dialogs to be displayed repeatedly on every refresh.  This
    was because the device was only removed from the 'device_paths' vector
    when it wasn't usable [1]; not when it didn't exist or was invalid, when
    the libparted ped_device_get() call failed.  Fix this.
    
    [1] Usable device as implemented by useable_device()
        Must not have a large sector size when GParted is built with an old
        version of libparted which doesn't support large sector sizes and
        must be able to read the first sector.
    
    Bug 756434 - GParted dumps core when passing non-existent or invalid
                 device on the command line

 src/GParted_Core.cc |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 780aa18..8f6be31 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -252,11 +252,10 @@ void GParted_Core::set_devices_thread( std::vector<Device> * pdevices )
 #endif
 
                        PedDevice* lp_device = ped_device_get( device_paths[t].c_str() );
-                       if ( lp_device )
+                       if ( lp_device == NULL || ! useable_device( lp_device ) )
                        {
-                               if ( ! useable_device( lp_device ) )
-                                       // Remove this disk device which isn't useable
-                                       device_paths.erase( device_paths.begin() + t );
+                               // Remove this disk device which isn't useable
+                               device_paths.erase( device_paths.begin() + t );
                        }
                }
        }


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