aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsylvaintv2011-06-01 23:49:19 +0200
committersylvaintv2011-06-01 23:49:19 +0200
commit3429a14c119752daa8d17c499dbffb27a3fe23a5 (patch)
tree97bac6b3ef1f050011e96579a7bcf1378c9d005f
parent9717d5be6f416a36dfb81e1c47c9cea518b5d018 (diff)
downloadscummvm-rg350-3429a14c119752daa8d17c499dbffb27a3fe23a5.tar.gz
scummvm-rg350-3429a14c119752daa8d17c499dbffb27a3fe23a5.tar.bz2
scummvm-rg350-3429a14c119752daa8d17c499dbffb27a3fe23a5.zip
TOON: Fix crash #3308220
Bug #3308220: "Crashes" Added clipping to magnifier effect
-rw-r--r--engines/toon/toon.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp
index 44c747c4c4..e5c2cc0952 100644
--- a/engines/toon/toon.cpp
+++ b/engines/toon/toon.cpp
@@ -466,20 +466,24 @@ void ToonEngine::doMagnifierEffect() {
byte tempBuffer[25 * 25];
for (int32 y = -12; y <= 12; y++) {
+ int32 cy = CLIP<int32>(posY + y, 0, TOON_BACKBUFFER_HEIGHT-1);
for (int32 x = -12; x <= 12; x++) {
+ int32 cx = CLIP<int32>(posX + x, 0, TOON_BACKBUFFER_WIDTH-1);
int32 destPitch = surface.pitch;
- uint8 *curRow = (uint8 *)surface.pixels + (posY + y) * destPitch + (posX + x);
+ uint8 *curRow = (uint8 *)surface.pixels + cy * destPitch + cx;
tempBuffer[(y + 12) * 25 + x + 12] = *curRow;
}
}
for (int32 y = -12; y <= 12; y++) {
+ int32 cy = CLIP<int32>(posY + y, 0, TOON_BACKBUFFER_HEIGHT-1);
for (int32 x = -12; x <= 12; x++) {
int32 dist = y * y + x * x;
if (dist > 144)
continue;
+ int32 cx = CLIP<int32>(posX + x, 0, TOON_BACKBUFFER_WIDTH-1);
int32 destPitch = surface.pitch;
- uint8 *curRow = (uint8 *)surface.pixels + (posY + y) * destPitch + (posX + x);
+ uint8 *curRow = (uint8 *)surface.pixels + cy * destPitch + cx;
int32 lerp = (512 + intSqrt[dist] * 256 / 12);
*curRow = tempBuffer[(y * lerp / 1024 + 12) * 25 + x * lerp / 1024 + 12];
}