mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-21 14:59:34 +00:00
kern/file: Do not leak device_name on error in grub_file_open()
If we have an error in grub_file_open() before we free device_name, we will leak it. Free device_name in the error path and null out the pointer in the good path once we free it there. Signed-off-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
6fe755c5c0
commit
f1ce0e15e7
1 file changed
+2
@@ -79,6 +79,7 @@ grub_file_open (const char *name, enum grub_file_type type)
|
||||
|
||||
device = grub_device_open (device_name);
|
||||
grub_free (device_name);
|
||||
device_name = NULL;
|
||||
if (! device)
|
||||
goto fail;
|
||||
|
||||
@@ -131,6 +132,7 @@ grub_file_open (const char *name, enum grub_file_type type)
|
||||
return file;
|
||||
|
||||
fail:
|
||||
grub_free (device_name);
|
||||
if (device)
|
||||
grub_device_close (device);
|
||||
|
||||
|
||||
Reference in new issue
Block a user