Fix a memory leak

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-07-06 17:41:49 +02:00
parent e1a0e1b428
commit c3bf5267b0

View file

@ -444,13 +444,22 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)),
continue; continue;
nb = grub_netbuff_alloc (sizeof (*pack)); nb = grub_netbuff_alloc (sizeof (*pack));
if (!nb) if (!nb)
{
grub_netbuff_free (nb);
return grub_errno; return grub_errno;
}
err = grub_netbuff_reserve (nb, sizeof (*pack) + 64 + 128); err = grub_netbuff_reserve (nb, sizeof (*pack) + 64 + 128);
if (err) if (err)
{
grub_netbuff_free (nb);
return err; return err;
}
err = grub_netbuff_push (nb, sizeof (*pack) + 64); err = grub_netbuff_push (nb, sizeof (*pack) + 64);
if (err) if (err)
{
grub_netbuff_free (nb);
return err; return err;
}
pack = (void *) nb->data; pack = (void *) nb->data;
done = 1; done = 1;
grub_memset (pack, 0, sizeof (*pack) + 64); grub_memset (pack, 0, sizeof (*pack) + 64);
@ -480,6 +489,7 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)),
target.ipv4 = 0xffffffff; target.ipv4 = 0xffffffff;
err = grub_net_send_ip_packet (&ifaces[j], &target, nb); err = grub_net_send_ip_packet (&ifaces[j], &target, nb);
grub_netbuff_free (nb);
if (err) if (err)
return err; return err;
} }
@ -491,6 +501,7 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)),
err = GRUB_ERR_NONE; err = GRUB_ERR_NONE;
for (j = 0; j < ncards; j++) for (j = 0; j < ncards; j++)
{ {
grub_free (ifaces[j].name);
if (!ifaces[j].prev) if (!ifaces[j].prev)
continue; continue;
grub_error_push (); grub_error_push ();
@ -499,6 +510,7 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)),
ifaces[j].card->name); ifaces[j].card->name);
} }
grub_free (ifaces);
return err; return err;
} }