From f1d44bdf8cbcf69805713f042b16480227e14d6c Mon Sep 17 00:00:00 2001 From: richiesams Date: Sat, 17 Aug 2013 20:34:44 -0500 Subject: ZVISION: Protect against indicies that are more than an imageWidth/Height from the actual image dimensions --- engines/zvision/render_table.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp index 7188530075..ec0cdba7c2 100644 --- a/engines/zvision/render_table.cpp +++ b/engines/zvision/render_table.cpp @@ -114,15 +114,17 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, int16 im int16 sourceXIndex = x + _internalBuffer[index].x; if (wrap) { - if (sourceXIndex >= imageWidth) { + while (sourceXIndex >= imageWidth) { sourceXIndex -= imageWidth; - } else if (sourceXIndex < 0) { + } + while (sourceXIndex < 0) { sourceXIndex += imageWidth; } - if (sourceYIndex >= imageHeight) { + while (sourceYIndex >= imageHeight) { sourceYIndex -= imageHeight; - } else if (sourceYIndex < 0) { + } + while (sourceYIndex < 0) { sourceYIndex += imageHeight; } } else { -- cgit v1.2.3