From c7564b8e133c0c9a069960b246487050db2f5d01 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 22 Jun 2012 22:02:47 +0200 Subject: [PATCH] * grub-core/net/net.c (grub_net_fs_open): Free resources on failed open. --- ChangeLog | 4 ++++ grub-core/net/net.c | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) 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);