* grub-core/kern/file.c (grub_file_open): Free file->name on failure.

(grub_file_close): Free file->name.
This commit is contained in:
Vladimir Serbinenko 2013-11-18 02:41:42 +01:00
parent 7bbb60cfbd
commit 33d02a42d6
2 changed files with 9 additions and 3 deletions

View file

@ -1,3 +1,8 @@
2013-11-18 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/file.c (grub_file_open): Free file->name on failure.
(grub_file_close): Free file->name.
2013-11-18 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/verify.c (free_pk): Plug memory leak.

View file

@ -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;
}