bootp: fix memory leak in grub_cmd_dhcpopt
This commit is contained in:
parent
76eac44af3
commit
5b8ddf6e03
1 changed files with 8 additions and 4 deletions
|
@ -368,6 +368,7 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
|
||||||
|
|
||||||
if (grub_strcmp (args[3], "string") == 0)
|
if (grub_strcmp (args[3], "string") == 0)
|
||||||
{
|
{
|
||||||
|
grub_err_t err = GRUB_ERR_NONE;
|
||||||
char *val = grub_malloc (taglength + 1);
|
char *val = grub_malloc (taglength + 1);
|
||||||
if (!val)
|
if (!val)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
@ -376,8 +377,9 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
|
||||||
if (args[0][0] == '-' && args[0][1] == 0)
|
if (args[0][0] == '-' && args[0][1] == 0)
|
||||||
grub_printf ("%s\n", val);
|
grub_printf ("%s\n", val);
|
||||||
else
|
else
|
||||||
return grub_env_set (args[0], val);
|
err = grub_env_set (args[0], val);
|
||||||
return GRUB_ERR_NONE;
|
grub_free (val);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grub_strcmp (args[3], "number") == 0)
|
if (grub_strcmp (args[3], "number") == 0)
|
||||||
|
@ -399,6 +401,7 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
|
||||||
|
|
||||||
if (grub_strcmp (args[3], "hex") == 0)
|
if (grub_strcmp (args[3], "hex") == 0)
|
||||||
{
|
{
|
||||||
|
grub_err_t err = GRUB_ERR_NONE;
|
||||||
char *val = grub_malloc (2 * taglength + 1);
|
char *val = grub_malloc (2 * taglength + 1);
|
||||||
int i;
|
int i;
|
||||||
if (!val)
|
if (!val)
|
||||||
|
@ -412,8 +415,9 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
|
||||||
if (args[0][0] == '-' && args[0][1] == 0)
|
if (args[0][0] == '-' && args[0][1] == 0)
|
||||||
grub_printf ("%s\n", val);
|
grub_printf ("%s\n", val);
|
||||||
else
|
else
|
||||||
return grub_env_set (args[0], val);
|
err = grub_env_set (args[0], val);
|
||||||
return GRUB_ERR_NONE;
|
grub_free (val);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
|
|
Loading…
Reference in a new issue