]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
font: Assign null_font to glyphs in ascii_font_glyph[]
authorZhang Boyang <zhangboyang.id@gmail.com>
Fri, 28 Oct 2022 09:29:16 +0000 (17:29 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Mon, 14 Nov 2022 19:24:39 +0000 (20:24 +0100)
The calculations in blit_comb() need information from glyph's font, e.g.
grub_font_get_xheight(main_glyph->font). However, main_glyph->font is
NULL if main_glyph comes from ascii_font_glyph[]. Therefore
grub_font_get_*() crashes because of NULL pointer.

There is already a solution, the null_font. So, assign it to those glyphs
in ascii_font_glyph[].

Reported-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/font/font.c

index cf15dc2f9c5a8cab278f087bdbbd2c79c3f9013d..3821937e6435fdd672df8821de51a7b35da2fa56 100644 (file)
@@ -137,7 +137,7 @@ ascii_glyph_lookup (grub_uint32_t code)
          ascii_font_glyph[current]->offset_x = 0;
          ascii_font_glyph[current]->offset_y = -2;
          ascii_font_glyph[current]->device_width = 8;
-         ascii_font_glyph[current]->font = NULL;
+         ascii_font_glyph[current]->font = &null_font;
 
          grub_memcpy (ascii_font_glyph[current]->bitmap,
                       &ascii_bitmaps[current * ASCII_BITMAP_SIZE],