summaryrefslogtreecommitdiff
path: root/libparted
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-05-27 14:35:07 +0200
committerJim Meyering <meyering@redhat.com>2011-05-27 14:35:07 +0200
commit861650a39b700f7226d0141ef6a0936eb59a2280 (patch)
tree63d7d854b77392c71cf45fec7cdff13e695564e6 /libparted
parent7ee08acc079d18b371fd8787965f5388b115c893 (diff)
downloadparted-861650a39b700f7226d0141ef6a0936eb59a2280.tar.gz
sun: avoid NULL-deref-on-OOM and an error-path leak
* libparted/labels/sun.c (sun_read): Don't dereference NULL on OOM. Don't leak a constraint when failing to add a partition.
Diffstat (limited to 'libparted')
-rw-r--r--libparted/labels/sun.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libparted/labels/sun.c b/libparted/labels/sun.c
index 75f7c6e..6148273 100644
--- a/libparted/labels/sun.c
+++ b/libparted/labels/sun.c
@@ -313,7 +313,6 @@ sun_read (PedDisk* disk)
int i;
PedPartition* part;
PedSector end, start, block;
- PedConstraint* constraint_exact;
PED_ASSERT (disk != NULL);
PED_ASSERT (disk->dev != NULL);
@@ -366,10 +365,14 @@ sun_read (PedDisk* disk)
part->num = i + 1;
part->fs_type = ped_file_system_probe (&part->geom);
- constraint_exact = ped_constraint_exact (&part->geom);
- if (!ped_disk_add_partition (disk, part, constraint_exact))
+ PedConstraint *constraint_exact
+ = ped_constraint_exact (&part->geom);
+ if (constraint_exact == NULL)
goto error;
+ bool ok = ped_disk_add_partition (disk, part, constraint_exact);
ped_constraint_destroy (constraint_exact);
+ if (!ok)
+ goto error;
}
return 1;