diff --git a/ChangeLog b/ChangeLog index 58bb6bdd4..e90b6b1ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012-06-22 Vladimir Serbinenko + + * grub-core/net/net.c (grub_net_fs_open): Free resources on failed open. + 2012-06-22 Vladimir Serbinenko * tests/util/grub-shell.in: Fix a typo. diff --git a/grub-core/net/net.c b/grub-core/net/net.c index ae7340cb2..01c5d32ce 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -1280,10 +1280,24 @@ grub_net_fs_open (struct grub_file *file_out, const char *name) err = file->device->net->protocol->open (file, name); if (err) - return err; + { + while (file->device->net->packs.first) + { + grub_netbuff_free (file->device->net->packs.first->nb); + grub_net_remove_packet (file->device->net->packs.first); + } + grub_free (file->device->net->name); + grub_free (file); + return err; + } bufio = grub_bufio_open (file, 32768); if (! bufio) { + while (file->device->net->packs.first) + { + grub_netbuff_free (file->device->net->packs.first->nb); + grub_net_remove_packet (file->device->net->packs.first); + } file->device->net->protocol->close (file); grub_free (file->device->net->name); grub_free (file);