Fix few potential memory misusage.

* grub-core/font/font.c (load_font_index): Don't free char_index to
	avoid double free.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-05-14 22:26:52 +02:00
parent 0cac83df85
commit 25a4533875
2 changed files with 15 additions and 5 deletions

View file

@ -1,3 +1,10 @@
2011-05-14 Vladimir Serbinenko <phcoder@gmail.com>
Fix few potential memory misusage.
* grub-core/font/font.c (load_font_index): Don't free char_index to
avoid double free.
2011-05-14 Vladimir Serbinenko <phcoder@gmail.com>
* docs/grub.texi (Installation): Fix several outdated claims.

View file

@ -316,10 +316,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
return 1;
font->bmp_idx = grub_malloc (0x10000 * sizeof (grub_uint16_t));
if (!font->bmp_idx)
{
grub_free (font->char_index);
return 1;
}
return 1;
grub_memset (font->bmp_idx, 0xff, 0x10000 * sizeof (grub_uint16_t));
@ -494,7 +491,7 @@ grub_font_load (const char *filename)
#endif
/* Allocate the font object. */
font = (grub_font_t) grub_malloc (sizeof (struct grub_font));
font = (grub_font_t) grub_zalloc (sizeof (struct grub_font));
if (!font)
goto fail;
@ -640,6 +637,11 @@ grub_font_load (const char *filename)
return 0;
fail:
if (file)
grub_file_close (file);
if (font)
font->file = 0;
free_font (font);
return 1;
}
@ -799,6 +801,7 @@ free_font (grub_font_t font)
grub_free (font->name);
grub_free (font->family);
grub_free (font->char_index);
grub_free (font->bmp_idx);
grub_free (font);
}
}