From 33d02a42d64cf06cada1c389e5abba4b9d196cc5 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 18 Nov 2013 02:41:42 +0100 Subject: [PATCH] * grub-core/kern/file.c (grub_file_open): Free file->name on failure. (grub_file_close): Free file->name. --- ChangeLog | 5 +++++ grub-core/kern/file.c | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index beac10772..ea7f15c33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-11-18 Vladimir Serbinenko + + * grub-core/kern/file.c (grub_file_open): Free file->name on failure. + (grub_file_close): Free file->name. + 2013-11-18 Vladimir Serbinenko * grub-core/commands/verify.c (free_pk): Plug memory leak. diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c index ea1817a41..24da12bb9 100644 --- a/grub-core/kern/file.c +++ b/grub-core/kern/file.c @@ -87,9 +87,6 @@ grub_file_open (const char *name) if (! file) goto fail; - file->name = grub_strdup (name); - grub_errno = GRUB_ERR_NONE; - file->device = device; if (device->disk && file_name[0] != '/') @@ -105,6 +102,9 @@ grub_file_open (const char *name) if ((file->fs->open) (file, file_name) != GRUB_ERR_NONE) goto fail; + file->name = grub_strdup (name); + grub_errno = GRUB_ERR_NONE; + for (filter = 0; file && filter < ARRAY_SIZE (grub_file_filters_enabled); filter++) if (grub_file_filters_enabled[filter]) @@ -187,6 +187,7 @@ grub_file_close (grub_file_t file) if (file->device) grub_device_close (file->device); + grub_free (file->name); grub_free (file); return grub_errno; }