2010-02-06 Vladimir Serbinenko <phcoder@gmail.com>
* partmap/sun.c (sun_partition_map_iterate): Restructure flow to fix buggy hook call and memory leak.
This commit is contained in:
parent
6846cec5f7
commit
f51a90d0cf
2 changed files with 43 additions and 26 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2010-02-06 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* partmap/sun.c (sun_partition_map_iterate): Restructure flow to fix
|
||||||
|
buggy hook call and memory leak.
|
||||||
|
|
||||||
2010-02-06 Vladimir Serbinenko <phcoder@gmail.com>
|
2010-02-06 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* commands/ls.c (grub_ls_list_files): Free pathname on exit.
|
* commands/ls.c (grub_ls_list_files): Free pathname on exit.
|
||||||
|
|
|
@ -91,6 +91,7 @@ sun_partition_map_iterate (grub_disk_t disk,
|
||||||
struct grub_disk raw;
|
struct grub_disk raw;
|
||||||
struct grub_sun_block block;
|
struct grub_sun_block block;
|
||||||
int partnum;
|
int partnum;
|
||||||
|
grub_err_t err;
|
||||||
|
|
||||||
raw = *disk;
|
raw = *disk;
|
||||||
raw.partition = 0;
|
raw.partition = 0;
|
||||||
|
@ -100,14 +101,26 @@ sun_partition_map_iterate (grub_disk_t disk,
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
p->partmap = &grub_sun_partition_map;
|
p->partmap = &grub_sun_partition_map;
|
||||||
if (grub_disk_read (&raw, 0, 0, sizeof (struct grub_sun_block),
|
err = grub_disk_read (&raw, 0, 0, sizeof (struct grub_sun_block),
|
||||||
&block) == GRUB_ERR_NONE)
|
&block);
|
||||||
|
if (err)
|
||||||
{
|
{
|
||||||
|
grub_free (p);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
if (GRUB_PARTMAP_SUN_MAGIC != grub_be_to_cpu16 (block.magic))
|
if (GRUB_PARTMAP_SUN_MAGIC != grub_be_to_cpu16 (block.magic))
|
||||||
grub_error (GRUB_ERR_BAD_PART_TABLE, "not a sun partition table");
|
{
|
||||||
|
grub_free (p);
|
||||||
|
return grub_error (GRUB_ERR_BAD_PART_TABLE,
|
||||||
|
"not a sun partition table");
|
||||||
|
}
|
||||||
|
|
||||||
if (! grub_sun_is_valid (&block))
|
if (! grub_sun_is_valid (&block))
|
||||||
grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid checksum");
|
{
|
||||||
|
grub_free (p);
|
||||||
|
return grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid checksum");
|
||||||
|
}
|
||||||
|
|
||||||
/* Maybe another error value would be better, because partition
|
/* Maybe another error value would be better, because partition
|
||||||
table _is_ recognized but invalid. */
|
table _is_ recognized but invalid. */
|
||||||
|
@ -131,7 +144,6 @@ sun_partition_map_iterate (grub_disk_t disk,
|
||||||
partnum = GRUB_PARTMAP_SUN_MAX_PARTS;
|
partnum = GRUB_PARTMAP_SUN_MAX_PARTS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
grub_free (p);
|
grub_free (p);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue