[parted-devel] [PATCH 2/5] libparted: Fix potential NULL dereference in ped_disk_next_partition

Brian C. Lane bcl at redhat.com
Wed Feb 15 19:57:08 GMT 2023


---
 libparted/disk.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libparted/disk.c b/libparted/disk.c
index e1a3489..6c82877 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -1718,8 +1718,11 @@ ped_disk_next_partition (const PedDisk* disk, const PedPartition* part)
 		return part->part_list ? part->part_list : part->next;
 	if (part->next)
 		return part->next;
-	if (part->type & PED_PARTITION_LOGICAL)
+	if (part->type & PED_PARTITION_LOGICAL) {
+		if (!ped_disk_extended_partition (disk))
+			return NULL;
 		return ped_disk_extended_partition (disk)->next;
+	}
 	return NULL;
 }
 
-- 
2.39.1




More information about the parted-devel mailing list