From 31db44c74a96f8e2b495205d18525449e9b29543 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 15 Feb 2023 10:13:58 -0800
Subject: [PATCH 19/24] libparted: Fix potential NULL dereference in
 ped_disk_next_partition

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

diff --git a/libparted/disk.c b/libparted/disk.c
index 5aaac5a..405400e 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -1552,8 +1552,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.33.0

