]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
memory leak fix in grub_script_execute_cmdline
authorBVK Chaitanya <bvk.groups@gmail.com>
Wed, 19 May 2010 04:55:41 +0000 (10:25 +0530)
committerBVK Chaitanya <bvk.groups@gmail.com>
Wed, 19 May 2010 04:55:41 +0000 (10:25 +0530)
include/grub/script_sh.h
script/argv.c
script/execute.c

index 5455fc763436c7243d8a57b8c4e341c59ec26b46..9199a539ef09a4566c6ceba10969a6769c1a9cbc 100644 (file)
@@ -66,7 +66,7 @@ struct grub_script_arg
 /* An argument vector.  */
 struct grub_script_argv
 {
-  int argc;
+  unsigned argc;
   char **args;
 };
 
index 4974178cc90b6298575bd427ade398b161b328c2..56274f263fe5d350305d43d25a9a032d017eacd1 100644 (file)
@@ -29,6 +29,7 @@ round_up_exp (unsigned v)
   v |= v >> 4;
   v |= v >> 8;
   v |= v >> 16;
+
   if (sizeof (v) > 4)
     v |= v >> 32;
 
@@ -41,7 +42,7 @@ round_up_exp (unsigned v)
 void
 grub_script_argv_free (struct grub_script_argv *argv)
 {
-  int i;
+  unsigned i;
 
   if (argv->args)
     {
index 2040be13cd53d6364e58902177b7b16f2a5fe378..6a755a0402a415752098ba4c5932734f6961aa08 100644 (file)
@@ -77,7 +77,7 @@ grub_script_env_get (const char *name, grub_script_arg_type_t type)
     }
   else if (grub_strcmp (name, "*") == 0)
     {
-      int i;
+      unsigned i;
 
       for (i = 0; ! errors && i < scope->argv.argc; i++)
        if (type == GRUB_SCRIPT_ARG_TYPE_VAR)
@@ -97,7 +97,7 @@ grub_script_env_get (const char *name, grub_script_arg_type_t type)
     }
   else if (grub_strcmp (name, "@") == 0)
     {
-      int i;
+      unsigned i;
 
       for (i = 0; ! errors && i < scope->argv.argc; i++)
        {
@@ -287,6 +287,7 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
          grub_snprintf (errnobuf, sizeof (errnobuf), "%d", grub_errno);
          grub_env_set ("?", errnobuf);
 
+         grub_script_argv_free (&argv);
          grub_print_error ();
 
          return 0;
@@ -353,8 +354,8 @@ grub_script_execute_cmdif (struct grub_script_cmd *cmd)
 grub_err_t
 grub_script_execute_cmdfor (struct grub_script_cmd *cmd)
 {
-  int i;
-  int result;
+  unsigned i;
+  grub_err_t result;
   struct grub_script_argv argv;
   struct grub_script_cmdfor *cmdfor = (struct grub_script_cmdfor *) cmd;