From 29f5210b3fd2fdd9500cf81e91fbe15d8af827f7 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 12 Aug 2016 15:27:36 +0200 Subject: DM: Add sanity check to blitToBimap --- engines/dm/gfx.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 1a1de67585..b5aa123db1 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1130,9 +1130,12 @@ void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 destWidth = destByteWidth * 2; for (uint16 y = 0; y < box._y2 + 1 - box._y1; ++y) // + 1 for inclusive boundaries for (uint16 x = 0; x < box._x2 + 1 - box._x1; ++x) { // + 1 for inclusive boundaries - byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x]; - if (srcPixel != transparent) - destBitmap[destWidth * (y + box._y1) + box._x1 + x] = srcPixel; + if (srcX + x < srcWidth && y + srcY < srcHeight + && box._x1 + x < destWidth && y + box._y1 < destHight) { + byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x]; + if (srcPixel != transparent) + destBitmap[destWidth * (y + box._y1) + box._x1 + x] = srcPixel; + } } } -- cgit v1.2.3