[Scummvm-cvs-logs] SF.net SVN: scummvm:[54408] scummvm/trunk/engines/cruise
tdhs at users.sourceforge.net
tdhs at users.sourceforge.net
Sun Nov 21 13:05:15 CET 2010
Revision: 54408
http://scummvm.svn.sourceforge.net/scummvm/?rev=54408&view=rev
Author: tdhs
Date: 2010-11-21 12:05:15 +0000 (Sun, 21 Nov 2010)
Log Message:
-----------
CRUISE: Fix Memory Accesses Errors and Leaks Reported By Valgrind
Most of these fixes are fairly simple, though the clamping of ArrayStates accesses in object.cpp _might_ cause regressions. None are obvious on basic playtest check, but the game will need a full playtest.
Modified Paths:
--------------
scummvm/trunk/engines/cruise/cell.cpp
scummvm/trunk/engines/cruise/object.cpp
scummvm/trunk/engines/cruise/sound.cpp
Modified: scummvm/trunk/engines/cruise/cell.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cell.cpp 2010-11-21 11:04:52 UTC (rev 54407)
+++ scummvm/trunk/engines/cruise/cell.cpp 2010-11-21 12:05:15 UTC (rev 54408)
@@ -65,9 +65,7 @@
if (currentHead2->type != 5) {
int16 lvar2;
- getSingleObjectParam(currentHead2->overlay, currentHead2->idx, 2, &lvar2);
-
- if (lvar2 >= var)
+ if(getSingleObjectParam(currentHead2->overlay, currentHead2->idx, 2, &lvar2) >= 0 && lvar2 >= var)
break;
}
Modified: scummvm/trunk/engines/cruise/object.cpp
===================================================================
--- scummvm/trunk/engines/cruise/object.cpp 2010-11-21 11:04:52 UTC (rev 54407)
+++ scummvm/trunk/engines/cruise/object.cpp 2010-11-21 12:05:15 UTC (rev 54408)
@@ -79,6 +79,12 @@
state = globalVars[overlayTable[overlayIdx].state + ptr->_stateTableIdx];
ptr2 = &ovlData->arrayStates[ptr->_firstStateIdx + state];
+
+ if (ptr->_firstStateIdx + state < 0) {
+ debug(0, "Invalid Negative arrayState index in getMultipleObjectParam(overlayIdx: %d, objectIdx: %d)... Forcing to 0", overlayIdx, objectIdx);
+ ptr2 = &ovlData->arrayStates[0];
+ }
+
state2 = ptr2->state;
break;
}
@@ -242,6 +248,11 @@
state = globalVars[overlayTable[overlayIdx].state + ptr->_stateTableIdx];
ptr2 = &ovlData->arrayStates[ptr->_firstStateIdx + state];
+
+ if (ptr->_firstStateIdx + state < 0) {
+ debug(0, "Invalid Negative arrayState index in getSingleObjectParam(overlayIdx: %d, param2: %d, param3: %d)... Forcing to 0", overlayIdx, param2, param3);
+ ptr2 = &ovlData->arrayStates[0];
+ }
break;
}
case VARIABLE: {
Modified: scummvm/trunk/engines/cruise/sound.cpp
===================================================================
--- scummvm/trunk/engines/cruise/sound.cpp 2010-11-21 11:04:52 UTC (rev 54407)
+++ scummvm/trunk/engines/cruise/sound.cpp 2010-11-21 12:05:15 UTC (rev 54408)
@@ -40,6 +40,7 @@
public:
typedef void (*UpdateCallback)(void *);
+ PCSoundDriver() { _upCb = NULL, _upRef = NULL, _musicVolume = 0, _sfxVolume = 0; }
virtual ~PCSoundDriver() {}
virtual void setupChannel(int channel, const byte *data, int instrument, int volume) = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list