* grub-core/normal/main.c: Fix freed memory dereference.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-05-04 13:50:16 +02:00
parent 03f7c8c304
commit 14af86e41b
2 changed files with 14 additions and 3 deletions

View file

@ -1,3 +1,7 @@
2013-05-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/normal/main.c: Fix freed memory dereference.
2013-05-04 Vladimir Serbinenko <phcoder@gmail.com>
Fix several memory leaks.

View file

@ -163,8 +163,9 @@ static grub_menu_t
read_config_file (const char *config)
{
grub_file_t file;
const char *old_file, *old_dir;
char *old_file = 0, *old_dir = 0;
char *config_dir, *ptr = 0;
const char *ctmp;
grub_menu_t newmenu;
@ -183,8 +184,12 @@ read_config_file (const char *config)
if (! file)
return 0;
old_file = grub_env_get ("config_file");
old_dir = grub_env_get ("config_directory");
ctmp = grub_env_get ("config_file");
if (ctmp)
old_file = grub_strdup (ctmp);
ctmp = grub_env_get ("config_directory");
if (ctmp)
old_dir = grub_strdup (ctmp);
grub_env_set ("config_file", config);
config_dir = grub_strdup (config);
if (config_dir)
@ -220,6 +225,8 @@ read_config_file (const char *config)
grub_env_set ("config_directory", old_dir);
else
grub_env_unset ("config_directory");
grub_free (old_file);
grub_free (old_dir);
grub_file_close (file);