ed1787d
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
ed1787d
From: Zhang Boyang <zhangboyang.id@gmail.com>
ed1787d
Date: Fri, 28 Oct 2022 17:29:16 +0800
ed1787d
Subject: [PATCH] font: Assign null_font to glyphs in ascii_font_glyph[]
ed1787d
ed1787d
The calculations in blit_comb() need information from glyph's font, e.g.
ed1787d
grub_font_get_xheight(main_glyph->font). However, main_glyph->font is
ed1787d
NULL if main_glyph comes from ascii_font_glyph[]. Therefore
ed1787d
grub_font_get_*() crashes because of NULL pointer.
ed1787d
ed1787d
There is already a solution, the null_font. So, assign it to those glyphs
ed1787d
in ascii_font_glyph[].
ed1787d
ed1787d
Reported-by: Daniel Axtens <dja@axtens.net>
ed1787d
Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
ed1787d
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
ed1787d
(cherry picked from commit dd539d695482069d28b40f2d3821f710cdcf6ee6)
ed1787d
---
ed1787d
 grub-core/font/font.c | 2 +-
ed1787d
 1 file changed, 1 insertion(+), 1 deletion(-)
ed1787d
ed1787d
diff --git a/grub-core/font/font.c b/grub-core/font/font.c
ed1787d
index 29fbb94294..e6616e610c 100644
ed1787d
--- a/grub-core/font/font.c
ed1787d
+++ b/grub-core/font/font.c
ed1787d
@@ -137,7 +137,7 @@ ascii_glyph_lookup (grub_uint32_t code)
ed1787d
 	  ascii_font_glyph[current]->offset_x = 0;
ed1787d
 	  ascii_font_glyph[current]->offset_y = -2;
ed1787d
 	  ascii_font_glyph[current]->device_width = 8;
ed1787d
-	  ascii_font_glyph[current]->font = NULL;
ed1787d
+	  ascii_font_glyph[current]->font = &null_font;
ed1787d
 
ed1787d
 	  grub_memcpy (ascii_font_glyph[current]->bitmap,
ed1787d
 		       &ascii_bitmaps[current * ASCII_BITMAP_SIZE],