[parted-devel] [PATCH 86/86] parted.c: Make sure dev_name is freed

Brian C. Lane bcl at redhat.com
Tue Jul 24 01:26:21 BST 2018


If there was a problem with ped_device_get or ped_device_open it would not be freed.

Related: rhbz#1602652
---
 parted/parted.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/parted/parted.c b/parted/parted.c
index dae35a5..c95fbbf 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1100,6 +1100,7 @@ do_print (PedDevice** dev, PedDisk** diskp)
         if (has_devices_arg) {
                 char*           dev_name;
                 PedDevice*      current_dev = NULL;
+                int             status = 0;
 
                 ped_device_probe_all();
 
@@ -1115,14 +1116,11 @@ do_print (PedDevice** dev, PedDisk** diskp)
                 ped_device_free_all ();
 
                 *dev = ped_device_get (dev_name);
-                if (!*dev)
-		        return 0;
-                if (!ped_device_open (*dev))
-                        return 0;
-
+                if (*dev && ped_device_open (*dev))
+                    status = 1;
                 free (dev_name);
 
-                return 1;
+                return status;
         }
 
         else if (has_list_arg)
-- 
2.17.1




More information about the parted-devel mailing list