mirror of
https://git.proxmox.com/git/grub2
synced 2025-08-13 18:09:37 +00:00
normal/completion: Fix leaking of memory when processing a completion
It is possible for the code to reach the end of the function without freeing the memory allocated to argv and argc still to be 0. We should always call grub_free(argv). The grub_free() will handle a NULL argument correctly if it reaches that code without the memory being allocated. Fixes: CID 96672 Signed-off-by: Darren Kenny <darren.kenny@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
parent
95bc016dba
commit
9213575b7a
@ -401,8 +401,8 @@ char *
|
||||
grub_normal_do_completion (char *buf, int *restore,
|
||||
void (*hook) (const char *, grub_completion_type_t, int))
|
||||
{
|
||||
int argc;
|
||||
char **argv;
|
||||
int argc = 0;
|
||||
char **argv = NULL;
|
||||
|
||||
/* Initialize variables. */
|
||||
match = 0;
|
||||
@ -517,10 +517,8 @@ grub_normal_do_completion (char *buf, int *restore,
|
||||
|
||||
fail:
|
||||
if (argc != 0)
|
||||
{
|
||||
grub_free (argv[0]);
|
||||
grub_free (argv);
|
||||
}
|
||||
grub_free (argv[0]);
|
||||
grub_free (argv);
|
||||
grub_free (match);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user