]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2010-01-27 Robert Millan <rmh.grub@aybabtu.com>
authorRobert Millan <rmh@aybabtu.com>
Wed, 27 Jan 2010 01:49:11 +0000 (01:49 +0000)
committerRobert Millan <rmh@aybabtu.com>
Wed, 27 Jan 2010 01:49:11 +0000 (01:49 +0000)
* util/grub-fstest.c (fstest): Rewrite allocation, fixing a few
memleak conditions.

ChangeLog
util/grub-fstest.c

index e3988f1509311239da98933c0de70afd00540c09..c4930acb863db6500b78317e9c99bb3041366ac0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index bf30286a4f1490bbf0118a3a42a46507e1c28cc7..c03c43451c996e42aadc770531c807c8008bda6c 100644 (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;
-       }
+       grub_util_error (grub_errmsg);
+
+      argv[1] = loop_name;
+
       execute_command ("loopback", 2, argv);
-    }
 
-  grub_free (loop_name);
-  grub_free (host_file);
+      grub_free (loop_name);
+    }
 }
 
 static struct option options[] = {