On Wed, Dec 09, 2009 at 12:29:15PM +0100, Aurelien Jarno wrote: > > diff -ur parted-1.8.8.git.2009.07.19/libparted/arch/freebsd.c > > parted-1.8.8.git.2009.07.19.new/libparted/arch/freebsd.c > > --- parted-1.8.8.git.2009.07.19/libparted/arch/freebsd.c 2009-11-21 > > 10:35:29.000000000 +0100 > > +++ parted-1.8.8.git.2009.07.19.new/libparted/arch/freebsd.c > > 2009-11-21 10:35:56.000000000 +0100 > > @@ -1110,13 +1110,18 @@ > > int path_len = strlen (dev->path); > > int result_len = path_len + 16; > > char* result; > > + PedDisk* disk; > > + > > + disk = ped_disk_new (dev); > > + if (!disk) > > + return NULL; > > > > result = (char*) ped_malloc (result_len); > > if (!result) > > return NULL; > > > > /* append slice number (ad0, partition 1 => ad0s1)*/ > > - snprintf (result, result_len, "%ss%d", dev->path, num); > > + snprintf (result, result_len, strcmp (disk->type->name, "gpt") ? > > "%ss%d" : "%sp%d", dev->path, num); > > > > return result; > > Shouldn't disk be freed after use?
Good catch. This needed a new variable to cope with the !result early return. Here's a new patch. -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
diff -ur parted-1.8.8.git.2009.07.19/libparted/arch/freebsd.c parted-1.8.8.git.2009.07.19.new/libparted/arch/freebsd.c --- parted-1.8.8.git.2009.07.19/libparted/arch/freebsd.c 2009-12-09 21:54:30.000000000 +0100 +++ parted-1.8.8.git.2009.07.19.new/libparted/arch/freebsd.c 2009-12-09 21:57:18.000000000 +0100 @@ -1109,14 +1109,24 @@ { int path_len = strlen (dev->path); int result_len = path_len + 16; + int is_gpt; char* result; + PedDisk* disk; + + disk = ped_disk_new (dev); + if (!disk) + return NULL; result = (char*) ped_malloc (result_len); if (!result) return NULL; + is_gpt = !strcmp (disk->type->name, "gpt"); + + ped_disk_destroy (disk); + /* append slice number (ad0, partition 1 => ad0s1)*/ - snprintf (result, result_len, "%ss%d", dev->path, num); + snprintf (result, result_len, is_gpt ? "%sp%d" : "%ss%d", dev->path, num); return result; }