[parted-devel] [PATCH] libparted/labels/dos.c: Fix memory leak
Will Newton
will.newton at gmail.com
Tue Jul 25 09:58:39 UTC 2017
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 <willn at resin.io>
---
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
More information about the parted-devel
mailing list