[parted-devel] [PATCH 5/7] parted: Fix memory leaks in do_resizepart

Brian C. Lane bcl at redhat.com
Fri Jun 11 21:51:23 BST 2021


---
 parted/parted.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/parted/parted.c b/parted/parted.c
index ba152c3..22b5818 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1582,7 +1582,6 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
         /* Push the End value back onto the command_line, if it exists */
         if (end_size) {
             command_line_push_word(end_size);
-            free(end_size);
         }
 
         start = part->geom.start;
@@ -1590,7 +1589,7 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
         if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, &end_input))
                 goto error;
         _adjust_end_if_iec(&start, &end, range_end, end_input);
-        free(end_input);
+
         /* Do not move start of the partition */
         constraint = constraint_from_start_end_fixed_start (*dev, start, range_end);
         if (!ped_disk_set_partition_geom (disk, part, constraint,
@@ -1616,6 +1615,9 @@ error_destroy_constraint:
 error:
         if (range_end != NULL)
                 ped_geometry_destroy (range_end);
+        free(end_input);
+        free(end_size);
+
         return rc;
 }
 
-- 
2.31.1




More information about the parted-devel mailing list