[PATCH 3/5] gpt: don't leak a constraint upon partition-add failure

Jim Meyering meyering at redhat.com
Fri Jan 15 18:53:36 UTC 2010


* libparted/labels/gpt.c (gpt_read): Free constraint upon failure.
---
 libparted/labels/gpt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 76537fd..9d9876c 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1020,7 +1020,6 @@ gpt_read (PedDisk *disk)
       GuidPartitionEntry_t *pte
         = (GuidPartitionEntry_t *) ((char *) ptes + i * p_ent_size);
       PedPartition *part;
-      PedConstraint *constraint_exact;

       if (!guid_cmp (pte->PartitionTypeGuid, UNUSED_ENTRY_GUID))
         continue;
@@ -1032,9 +1031,10 @@ gpt_read (PedDisk *disk)
       part->fs_type = ped_file_system_probe (&part->geom);
       part->num = i + 1;

-      constraint_exact = ped_constraint_exact (&part->geom);
+      PedConstraint *constraint_exact = ped_constraint_exact (&part->geom);
       if (!ped_disk_add_partition (disk, part, constraint_exact))
         {
+          ped_constraint_destroy (constraint_exact);
           ped_partition_destroy (part);
           goto error_delete_all;
         }
--
1.6.6.556.gd6679




More information about the parted-devel mailing list