nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0572-font-Assign-null_font-to-glyphs-in-ascii_font_glyph.patch

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