From 66c3279b2f69a483ec3cc5ff1d8ed84e33621162 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 2 Feb 2012 02:38:17 +0100 Subject: GRAPHICS: Obtain pointer to dst surface after bounds checks in TTF renderer. This should really make sure we are not drawing outside the surface bounds. --- graphics/fonts/ttf.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/graphics/fonts/ttf.cpp b/graphics/fonts/ttf.cpp index faf59a9ec5..06231799ce 100644 --- a/graphics/fonts/ttf.cpp +++ b/graphics/fonts/ttf.cpp @@ -323,7 +323,6 @@ void TTFFont::drawChar(Surface *dst, byte chr, int x, int y, uint32 color) const int h = glyph.image.h; const uint8 *srcPos = (const uint8 *)glyph.image.getBasePtr(0, 0); - uint8 *dstPos = (uint8 *)dst->getBasePtr(x, y); // Make sure we are not drawing outside the screen bounds if (x < 0) { @@ -350,6 +349,8 @@ void TTFFont::drawChar(Surface *dst, byte chr, int x, int y, uint32 color) const if (h <= 0) return; + uint8 *dstPos = (uint8 *)dst->getBasePtr(x, y); + if (dst->format.bytesPerPixel == 1) { for (int cy = 0; cy < h; ++cy) { uint8 *rDst = dstPos; -- cgit v1.2.3