]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
search_wrap: fix memory leak
authorAndrei Borzenkov <arvidjaar@gmail.com>
Sat, 20 Jun 2015 20:38:19 +0000 (23:38 +0300)
committerAndrei Borzenkov <arvidjaar@gmail.com>
Sat, 20 Jun 2015 20:38:19 +0000 (23:38 +0300)
Found by: Coverity scan.
CID: 96675

grub-core/commands/search_wrap.c

index 3f75fecdf1d0b22890121beb6db643a1366ed2c7..d7fd26b9405bf653344606bd87bff95e4b2c4528 100644 (file)
@@ -175,7 +175,10 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
       var = "root";
     }
   else
-    return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+    {
+      grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+      goto out;
+    }
 
   if (state[SEARCH_LABEL].set)
     grub_search_label (id, var, state[SEARCH_NO_FLOPPY].set, 
@@ -187,8 +190,10 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
     grub_search_fs_file (id, var, state[SEARCH_NO_FLOPPY].set, 
                         hints, nhints);
   else
-    return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
+    grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
 
+out:
+  grub_free (hints);
   return grub_errno;
 }