From 18a0dc894d49ff1b141adbac13845999ad7541a7 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 20 Nov 2011 15:17:34 +0000 Subject: [PATCH] (svn r23283) -Fix: [NewGRF] Prevent against writing data for unknown fonts --- src/newgrf.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/newgrf.cpp b/src/newgrf.cpp index d8950fa397..5aee0f5d3c 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -6886,7 +6886,7 @@ static void LoadFontGlyph(ByteReader *buf) /* <12> * * B num_def Number of definitions - * B font_size Size of font (0 = normal, 1 = small, 2 = large) + * B font_size Size of font (0 = normal, 1 = small, 2 = large, 3 = mono) * B num_char Number of consecutive glyphs * W base_char First character index */ @@ -6897,10 +6897,14 @@ static void LoadFontGlyph(ByteReader *buf) uint8 num_char = buf->ReadByte(); uint16 base_char = buf->ReadWord(); + if (size >= FS_END) { + grfmsg(1, "LoadFontGlyph: Size %u is not supported, ignoring", size); + } + grfmsg(7, "LoadFontGlyph: Loading %u glyph(s) at 0x%04X for size %u", num_char, base_char, size); for (uint c = 0; c < num_char; c++) { - SetUnicodeGlyph(size, base_char + c, _cur.spriteid); + if (size < FS_END) SetUnicodeGlyph(size, base_char + c, _cur.spriteid); _cur.nfo_line++; LoadNextSprite(_cur.spriteid++, _cur.file_index, _cur.nfo_line); }