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.
This commit is contained in:
Johannes Schickel 2012-02-02 02:38:17 +01:00
parent 6402d30874
commit 66c3279b2f

View File

@ -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;