search_wrap: fix memory leak

Found by: Coverity scan.
CID: 96675
This commit is contained in:
Andrei Borzenkov 2015-06-20 23:38:19 +03:00
parent 2f01f08103
commit 5af859bb77

View file

@ -175,7 +175,10 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
var = "root"; var = "root";
} }
else 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) if (state[SEARCH_LABEL].set)
grub_search_label (id, var, state[SEARCH_NO_FLOPPY].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, grub_search_fs_file (id, var, state[SEARCH_NO_FLOPPY].set,
hints, nhints); hints, nhints);
else 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; return grub_errno;
} }