From 89c0e30ddc3cd12d790da51c99a7d92d9e9739d0 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 28 Apr 2010 19:14:20 +0000 Subject: Only draw letters that actually fit on the surface. Should fix bug #2992268 (Reproducible crash creating Intuition formula) svn-id: r48829 --- engines/gob/draw.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'engines/gob') diff --git a/engines/gob/draw.cpp b/engines/gob/draw.cpp index 75177ff02d..ff6d558998 100644 --- a/engines/gob/draw.cpp +++ b/engines/gob/draw.cpp @@ -384,7 +384,12 @@ void Draw::drawString(const char *str, int16 x, int16 y, int16 color1, int16 col int16 transp, SurfaceDesc &dest, const Font &font) { while (*str != '\0') { - _vm->_video->drawLetter(*str, x, y, font, transp, color1, color2, dest); + const int16 charRight = x + font.getCharWidth(*str); + const int16 charBottom = y + font.getCharHeight(); + + if ((charRight <= dest.getWidth()) && (charBottom <= dest.getHeight())) + _vm->_video->drawLetter(*str, x, y, font, transp, color1, color2, dest); + x += font.getCharWidth(*str); str++; } -- cgit v1.2.3