From 6e0cef8fa046bd65f536cdc5726dc7fdebf6881a Mon Sep 17 00:00:00 2001 From: Archez Date: Fri, 12 Jan 2024 19:00:24 -0500 Subject: [PATCH] properly array bounds check the font table (#32) --- mm/src/code/z_kanfont.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/src/code/z_kanfont.c b/mm/src/code/z_kanfont.c index 1182b7a16..a186c84b5 100644 --- a/mm/src/code/z_kanfont.c +++ b/mm/src/code/z_kanfont.c @@ -181,8 +181,9 @@ void Font_LoadCharNES(PlayState* play, u8 codePointIndex, s32 offset) { int fontIdx = codePointIndex - 0x20; - if (codePointIndex < 0x8B) + if (fontIdx >= 0 && fontIdx < ARRAY_COUNT(fontTbl)) { memcpy(&font->charBuf[font->unk_11D88][offset], fontTbl[fontIdx], strlen(fontTbl[fontIdx]) + 1); + } // DmaMgr_SendRequest0(&font->charBuf[font->unk_11D88][offset], //&((u8*)SEGMENT_ROM_START(nes_font_static))[(codePointIndex - ' ') * FONT_CHAR_TEX_SIZE],