In read_table if we fail to add a partition to the disk then we should destroy that partition before returning an error.
Signed-off-by: Will Newton <[email protected]> --- libparted/labels/dos.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c index c1009db..0e343a4 100644 --- a/libparted/labels/dos.c +++ b/libparted/labels/dos.c @@ -1053,8 +1053,10 @@ read_table (PedDisk* disk, PedSector sector, int is_extended_table) = ped_constraint_exact (&part->geom); bool ok = ped_disk_add_partition (disk, part, constraint_exact); ped_constraint_destroy (constraint_exact); - if (!ok) + if (!ok) { + ped_partition_destroy (part); goto error; + } /* non-nested extended partition */ if (part->type == PED_PARTITION_EXTENDED) { -- 2.9.4

