[Scummvm-cvs-logs] scummvm master -> 587c1ad3106752e703197f8063bf03a0fb877561
m-kiewitz
m_kiewitz at users.sourceforge.net
Tue Feb 9 17:37:58 CET 2016
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
587c1ad310 AGI: Check xPos/yPos when building sprite lists
Commit: 587c1ad3106752e703197f8063bf03a0fb877561
https://github.com/scummvm/scummvm/commit/587c1ad3106752e703197f8063bf03a0fb877561
Author: Martin Kiewitz (m_kiewitz at users.sourceforge.net)
Date: 2016-02-09T17:37:28+01:00
Commit Message:
AGI: Check xPos/yPos when building sprite lists
And ignore sprites, that are placed outside of visual screen
Fixes memory corruption during intro of fan made Get Outta SQ game.
Original AGI did not do checks at all.
Changed paths:
engines/agi/sprite.cpp
diff --git a/engines/agi/sprite.cpp b/engines/agi/sprite.cpp
index c68641f..09935c9 100644
--- a/engines/agi/sprite.cpp
+++ b/engines/agi/sprite.cpp
@@ -106,6 +106,28 @@ void SpritesMgr::buildSpriteListAdd(uint16 givenOrderNr, ScreenObjEntry *screenO
spriteEntry.yPos = (screenObj->yPos) - (screenObj->ySize) + 1;
spriteEntry.xSize = screenObj->xSize;
spriteEntry.ySize = screenObj->ySize;
+
+ // Checking, if xPos/yPos/right/bottom are valid and do not go outside of playscreen (visual screen)
+ // Original AGI did not do this (but it then resulted in memory corruption)
+ if (spriteEntry.xPos < 0) {
+ warning("buildSpriteListAdd(): ignoring screen obj %d, b/c xPos < 0", screenObj->objectNr, spriteEntry.xPos);
+ return;
+ }
+ if (spriteEntry.yPos < 0) {
+ warning("buildSpriteListAdd(): ignoring screen obj %d, b/c yPos (%d) < 0", screenObj->objectNr, spriteEntry.yPos);
+ return;
+ }
+ int16 xRight = spriteEntry.xPos + spriteEntry.xSize;
+ if (xRight > SCRIPT_HEIGHT) {
+ warning("buildSpriteListAdd(): ignoring screen obj %d, b/c rightPos > %d", screenObj->objectNr, xRight, SCRIPT_WIDTH);
+ return;
+ }
+ int16 yBottom = spriteEntry.yPos + spriteEntry.ySize;
+ if (yBottom > SCRIPT_HEIGHT) {
+ warning("buildSpriteListAdd(): ignoring screen obj %d, b/c bottomPos > %d", screenObj->objectNr, yBottom, SCRIPT_HEIGHT);
+ return;
+ }
+
// warning("list-add: %d, %d, original yPos: %d, ySize: %d", spriteEntry.xPos, spriteEntry.yPos, screenObj->yPos, screenObj->ySize);
spriteEntry.backgroundBuffer = (uint8 *)malloc(spriteEntry.xSize * spriteEntry.ySize * 2); // for visual + priority data
assert(spriteEntry.backgroundBuffer);
More information about the Scummvm-git-logs
mailing list