From a2afc0f4d19f8eff5e9ebc49d51035970d4bcb8c Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 26 Jan 2011 19:03:13 +0000 Subject: GOB: Check font index for kFontCount svn-id: r55547 --- engines/gob/draw_v1.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'engines/gob/draw_v1.cpp') diff --git a/engines/gob/draw_v1.cpp b/engines/gob/draw_v1.cpp index d130f424c2..e528b6ad86 100644 --- a/engines/gob/draw_v1.cpp +++ b/engines/gob/draw_v1.cpp @@ -247,8 +247,7 @@ void Draw_v1::printTotText(int16 id) { if (*ptr != 0xBA) { _letterToPrint = (char) *ptr; spriteOperation(DRAW_DRAWLETTER); - _destSpriteX += - _fonts[_fontIndex]->getCharWidth(); + _destSpriteX += _fonts[_fontIndex]->getCharWidth(); ptr++; } else { cmd = ptrEnd[17] & 0x7F; @@ -401,12 +400,12 @@ void Draw_v1::spriteOperation(int16 operation) { break; case DRAW_PRINTTEXT: - font = _fonts[_fontIndex]; - if (!font) { + if ((_fontIndex >= kFontCount) || !_fonts[_fontIndex]) { warning("Trying to print \"%s\" with undefined font %d", _textToPrint, _fontIndex); break; } + font = _fonts[_fontIndex]; len = strlen(_textToPrint); dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _destSpriteX + len * font->getCharWidth() - 1, @@ -453,12 +452,12 @@ void Draw_v1::spriteOperation(int16 operation) { break; case DRAW_DRAWLETTER: - font = _fonts[_fontIndex]; - if (!font) { + if ((_fontIndex >= kFontCount) || !_fonts[_fontIndex]) { warning("Trying to print \'%c\' with undefined font %d", _letterToPrint, _fontIndex); break; } + font = _fonts[_fontIndex]; if (_fontToSprite[_fontIndex].sprite == -1) { dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _destSpriteX + font->getCharWidth() - 1, -- cgit v1.2.3