aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche
diff options
context:
space:
mode:
authorStrangerke2013-10-15 00:09:08 +0200
committerStrangerke2013-10-15 00:09:08 +0200
commit597690ae9d401844a6e842654e368710d60b2fc8 (patch)
tree2cd48d53ae79d9a278b0f22fc96338dc5a6ae708 /engines/avalanche
parent652331a3a97a7f0505692085a16083ca0e925900 (diff)
downloadscummvm-rg350-597690ae9d401844a6e842654e368710d60b2fc8.tar.gz
scummvm-rg350-597690ae9d401844a6e842654e368710d60b2fc8.tar.bz2
scummvm-rg350-597690ae9d401844a6e842654e368710d60b2fc8.zip
AVALANCHE: Fix memory corruption in background (drawpicture) blitting
Diffstat (limited to 'engines/avalanche')
-rw-r--r--engines/avalanche/graphics.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp
index bedb7f5506..151879d6c7 100644
--- a/engines/avalanche/graphics.cpp
+++ b/engines/avalanche/graphics.cpp
@@ -563,8 +563,17 @@ void GraphicManager::drawSprite(const SpriteInfo &sprite, byte picnum, int16 x,
void GraphicManager::drawPicture(Graphics::Surface &target, const Graphics::Surface picture, uint16 destX, uint16 destY) {
// Copy the picture to the given place on the screen.
- for (uint16 y = 0; y < picture.h; y++) {
- for (uint16 x = 0; x < picture.w; x++)
+ uint16 maxX = picture.w;
+ uint16 maxY = picture.h;
+
+ if (destX + maxX > target.w)
+ maxX = target.w - destX;
+
+ if (destY + maxY > target.h)
+ maxY = target.h - destY;
+
+ for (uint16 y = 0; y < maxY; y++) {
+ for (uint16 x = 0; x < maxX; x++)
*(byte *)target.getBasePtr(x + destX, y + destY) = *(const byte *)picture.getBasePtr(x, y);
}
}