Subject: bug#22920: closed (Re: bug#22920: [PATCH] libparted/disk.c(ped_disk_get_partition): Fix assert error)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 15 Apr 2016 01:03:02 +0000

Your bug report

#22920: [PATCH] libparted/disk.c(ped_disk_get_partition): Fix assert error

which was filed against the parted package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
22920: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22920
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#22920: [PATCH] libparted/disk.c(ped_disk_get_partition): Fix assert error
From: Phillip Susi <[email-masked]>
To: [email-masked]
Date: Thu, 14 Apr 2016 21:02:37 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

It seems this was already fixed:

 commit f5c628dd51c7d77ff939554425159ab6e8aef1c0
 Author: Brian C. Lane <[email-masked]>
 Date:   Mon Jul 13 16:43:11 2015 -0700

     parted: Fix crash with name command and no disklabel (#1226067)

     A typo (the last I think) from commit 7eac058 wasn't properly
checking
     the result of ped_disk_new so it could crash if there was no
disklabel
     on the device.

Subject: [PATCH] libparted/disk.c(ped_disk_get_partition): Fix assert error
From: lu4nx <[email-masked]>
To: [email-masked]
Cc: Xi Lu <[email-masked]>
Date: Sun, 6 Mar 2016 14:48:27 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

From: Xi Lu <[email-masked]>

if forget create a partition, and execute:

`name 1 grub`

ped_disk_get_partition() will trigger an exception:

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

diff --git a/libparted/disk.c b/libparted/disk.c
index fe82f44..9f36d10 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -1594,7 +1594,10 @@ ped_disk_get_partition (const PedDisk* disk, int num)
 {
 	PedPartition*	walk;
 
-	PED_ASSERT (disk != NULL);
+        if (disk == NULL) {
+          fprintf(stderr, "you must specify partition.");
+          return NULL;
+        }
 
 	for (walk = disk->part_list; walk;
 	     walk = ped_disk_next_partition (disk, walk)) {
-- 
2.5.0