From 3bac0aabd98d52eb2e5d33c8e192961f5f7368a1 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 11 Nov 2016 17:26:37 +0100 Subject: [PATCH] Fix buffer overrun when rendering goto() debug texture, closes #841 --- src/graphics/engine/engine.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index b2aa631f..3110cd37 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -4404,6 +4404,9 @@ void CEngine::UpdateGroundSpotTextures() { int px = x / 4.0f / 254.0f * size.x; int py = y / 4.0f / 254.0f * size.y; + // This can happen because the shadow??.png textures have a 1 pixel margin around them + if (px < 0 || px >= size.x || py < 0 || py >= size.y) + continue; shadowImg.SetPixelInt(Math::IntPoint(x-min.x, y-min.y), m_displayGotoImage->GetPixelInt(Math::IntPoint(px, py))); } }