2010-01-27 Robert Millan <rmh.grub@aybabtu.com>

* util/grub-fstest.c (fstest): Rewrite allocation, fixing a few
	memleak conditions.
This commit is contained in:
Robert Millan 2010-01-27 01:49:11 +00:00
parent 254e2ce596
commit af75a9f19a
2 changed files with 23 additions and 19 deletions

View File

@ -1,3 +1,8 @@
2010-01-27 Robert Millan <rmh.grub@aybabtu.com>
* util/grub-fstest.c (fstest): Rewrite allocation, fixing a few
memleak conditions.
2010-01-27 Carles Pina i Estany <carles@pina.cat>
* util/lvm.c: New macro LVM_DEV_MAPPER_STRING.

View File

@ -280,27 +280,29 @@ fstest (char **images, int num_disks, int cmd, int n, char **args)
{
char *host_file;
char *loop_name;
char *argv[3] = { "-p" };
char *argv[3];
int i;
argv[0] = "-p";
for (i = 0; i < num_disks; i++)
{
loop_name = grub_xasprintf ("loop%d", i);
host_file = grub_xasprintf ("(host)%s", images[i]);
if (!loop_name)
grub_util_error (grub_errmsg);
if (!loop_name || !host_file)
{
grub_free (loop_name);
grub_free (host_file);
grub_util_error (grub_errmsg);
return;
}
host_file = grub_xasprintf ("(host)%s", images[i]);
if (!host_file)
grub_util_error (grub_errmsg);
argv[1] = loop_name;
argv[2] = host_file;
if (execute_command ("loopback", 3, argv))
grub_util_error ("loopback command fails");
grub_free (loop_name);
grub_free (host_file);
}
grub_lvm_fini ();
@ -336,19 +338,16 @@ fstest (char **images, int num_disks, int cmd, int n, char **args)
for (i = 0; i < num_disks; i++)
{
grub_free (loop_name);
loop_name = grub_xasprintf ("loop%d", i);
if (!loop_name)
{
grub_free (host_file);
grub_util_error (grub_errmsg);
return;
}
execute_command ("loopback", 2, argv);
}
grub_util_error (grub_errmsg);
grub_free (loop_name);
grub_free (host_file);
argv[1] = loop_name;
execute_command ("loopback", 2, argv);
grub_free (loop_name);
}
}
static struct option options[] = {