[Parted-commits] GNU Parted Official Repository: Changes to 'master'
Jim Meyering
meyering at alioth.debian.org
Fri Jan 15 21:04:38 UTC 2010
gnulib | 2 +-
libparted/disk.c | 1 -
libparted/labels/bsd.c | 1 -
libparted/labels/dos.c | 9 +++++----
libparted/labels/gpt.c | 17 ++++++++++-------
5 files changed, 16 insertions(+), 14 deletions(-)
New commits:
commit 9573e0d524a60b8a749efca28d40840176a8ef61
Author: Jim Meyering <meyering at redhat.com>
Date: Fri Jan 15 21:11:22 2010 +0100
build: update gnulib submodule to latest
diff --git a/gnulib b/gnulib
index 0906b5f..4c52807 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 0906b5f3d776d1a91b4c1f2c244cb01b2c6aabcd
+Subproject commit 4c52807f41f238cf0e352317b2dc54f9ba0f0c4f
commit 358c9846a014247605d8da47b6917cac1344de00
Author: Jim Meyering <meyering at redhat.com>
Date: Fri Jan 15 20:14:38 2010 +0100
dos: don't leak a constraint upon partition-add failure
* libparted/labels/dos.c (read_table): Free constraint upon failure.
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index 6b8d6cb..339acf4 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -873,7 +873,6 @@ read_table (PedDisk* disk, PedSector sector, int is_extended_table)
PedPartition* part;
PedPartitionType type;
PedSector lba_offset;
- PedConstraint* constraint_exact;
PED_ASSERT (disk != NULL, return 0);
PED_ASSERT (disk->dev != NULL, return 0);
@@ -944,10 +943,12 @@ read_table (PedDisk* disk, PedSector sector, int is_extended_table)
if (type != PED_PARTITION_EXTENDED)
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))
- goto error;
+ PedConstraint *constraint_exact
+ = ped_constraint_exact (&part->geom);
+ bool ok = ped_disk_add_partition (disk, part, constraint_exact);
ped_constraint_destroy (constraint_exact);
+ if (!ok)
+ goto error;
/* non-nested extended partition */
if (part->type == PED_PARTITION_EXTENDED) {
commit d0cec198183be0b9989e4bc729c2930c7cdfe545
Author: Jim Meyering <meyering at redhat.com>
Date: Fri Jan 15 19:53:36 2010 +0100
gpt: don't leak a constraint upon partition-add failure
* libparted/labels/gpt.c (gpt_read): Free constraint upon failure.
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;
}
commit 952e4919befce199b096fd1bbde93ef7902239d3
Author: Jim Meyering <meyering at redhat.com>
Date: Fri Jan 15 19:34:00 2010 +0100
gpt: do not leak a GPT header on an error path
* libparted/labels/gpt.c (gpt_write): Avoid a leak by freeing the
header buffer after pth_get_raw call where it's used, but before
checking whether that pth_get_raw call succeeded.
Avoid another leak in identical just 10 lines down.
Add "FIXME: caution..." comments to warn about the duplication.
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index fe1f300..76537fd 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1208,11 +1208,13 @@ gpt_write (const PedDisk *disk)
goto error_free_ptes;
/* Write PTH and PTEs */
+ /* FIXME: Caution: this code is nearly identical to what's just below. */
if (_generate_header (disk, 0, ptes_crc, &gpt) != 0)
goto error_free_ptes;
- if ((pth_raw = pth_get_raw (disk->dev, gpt)) == NULL)
- goto error_free_ptes;
+ pth_raw = pth_get_raw (disk->dev, gpt);
pth_free (gpt);
+ if (pth_raw == NULL)
+ goto error_free_ptes;
int write_ok = ped_device_write (disk->dev, pth_raw, 1, 1);
free (pth_raw);
if (!write_ok)
@@ -1222,11 +1224,13 @@ gpt_write (const PedDisk *disk)
goto error_free_ptes;
/* Write Alternate PTH & PTEs */
+ /* FIXME: Caution: this code is nearly identical to what's just above. */
if (_generate_header (disk, 1, ptes_crc, &gpt) != 0)
goto error_free_ptes;
- if ((pth_raw = pth_get_raw (disk->dev, gpt)) == NULL)
- goto error_free_ptes;
+ pth_raw = pth_get_raw (disk->dev, gpt);
pth_free (gpt);
+ if (pth_raw == NULL)
+ goto error_free_ptes;
write_ok = ped_device_write (disk->dev, pth_raw, disk->dev->length - 1, 1);
free (pth_raw);
if (!write_ok)
commit 1528f147cbfaf3193a8e120af297d1f2d7961161
Author: Jim Meyering <meyering at redhat.com>
Date: Fri Jan 15 19:18:48 2010 +0100
libparted: remove unreachable code
* libparted/labels/gpt.c (gpt_write): Remove dead code.
* libparted/labels/bsd.c (bsd_partition_new): Likewise.
* libparted/disk.c (_ped_disk_alloc): Likewise.
diff --git a/libparted/disk.c b/libparted/disk.c
index 2d27b7c..b819d59 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -406,7 +406,6 @@ _ped_disk_alloc (const PedDevice* dev, const PedDiskType* disk_type)
disk->part_list = NULL;
return disk;
- free (disk);
error:
return NULL;
}
diff --git a/libparted/labels/bsd.c b/libparted/labels/bsd.c
index df531e9..e1b57e5 100644
--- a/libparted/labels/bsd.c
+++ b/libparted/labels/bsd.c
@@ -416,7 +416,6 @@ bsd_partition_new (const PedDisk* disk, PedPartitionType part_type,
}
return part;
- free (bsd_data);
error_free_part:
free (part);
error:
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 4ae7b59..fe1f300 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1240,7 +1240,6 @@ gpt_write (const PedDisk *disk)
free (ptes);
return ped_device_sync (disk->dev);
- free (pth_raw);
error_free_ptes:
free (ptes);
error:
More information about the Parted-commits
mailing list