[parted-devel] [PATCH] Handle ped_disk_get_last_partition_num(disk) == -1 gracefully

Soren Hansen soren at canonical.com
Wed Aug 6 17:54:04 UTC 2008


On Wed, Aug 06, 2008 at 07:37:04PM +0200, Jim Meyering wrote:
> > If ped_disk_get_last_partition_num(disk) fails (which it will if
> > disk is a loopback device), it will return -1. This in turn will
> > cause _disk_sync_part_table and  _dm_reread_part_table to attempt to
> > malloc a sizeof(int)*-1, which instantly causes a "Fatal: Out of
> > memory".
> >
> > This patch detects this case, and pretends the last partition id is 0.
> Thanks, but I prefer to keep declaration and first use together, when
> reasonable.

I do too. My preference for keeping declarations together at the top of
the function was just stronger, but I'm not insistant either way. :)

-- 
Soren Hansen               | 
Virtualisation specialist  | Ubuntu Server Team
Canonical Ltd.             | http://www.ubuntu.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: Digital signature
Url : http://lists.alioth.debian.org/pipermail/parted-devel/attachments/20080806/81d6decd/attachment.pgp 


More information about the parted-devel mailing list