diff options
author | Kari Salminen | 2008-08-09 20:55:01 +0000 |
---|---|---|
committer | Kari Salminen | 2008-08-09 20:55:01 +0000 |
commit | 983a4f21e51814d4f2a65480c6e571ca5a6fb0c3 (patch) | |
tree | 5bf3bca0b15dc9998f8c46d20a41fcf1c22544fe /engines | |
parent | 09119829549c13c06aa5af80ca01197eb8ce7cda (diff) | |
download | scummvm-rg350-983a4f21e51814d4f2a65480c6e571ca5a6fb0c3.tar.gz scummvm-rg350-983a4f21e51814d4f2a65480c6e571ca5a6fb0c3.tar.bz2 scummvm-rg350-983a4f21e51814d4f2a65480c6e571ca5a6fb0c3.zip |
Converted animDataTable from a plain array to a Common::Array. Should help to catch out of bounds access errors which may cause memory corruption.
svn-id: r33726
Diffstat (limited to 'engines')
-rw-r--r-- | engines/cine/anim.cpp | 2 | ||||
-rw-r--r-- | engines/cine/anim.h | 2 | ||||
-rw-r--r-- | engines/cine/cine.cpp | 4 | ||||
-rw-r--r-- | engines/cine/gfx.cpp | 6 |
4 files changed, 9 insertions, 5 deletions
diff --git a/engines/cine/anim.cpp b/engines/cine/anim.cpp index 1036078fb3..a670328c12 100644 --- a/engines/cine/anim.cpp +++ b/engines/cine/anim.cpp @@ -49,7 +49,7 @@ struct AnimHeader2Struct { uint16 field_E; }; -AnimData animDataTable[NUM_MAX_ANIMDATA]; +Common::Array<AnimData> animDataTable; static const AnimDataEntry transparencyData[] = { {"ALPHA", 0xF}, diff --git a/engines/cine/anim.h b/engines/cine/anim.h index 317654064b..8b1541eb3f 100644 --- a/engines/cine/anim.h +++ b/engines/cine/anim.h @@ -150,7 +150,7 @@ public: #define NUM_MAX_ANIMDATA 255 -extern AnimData animDataTable[NUM_MAX_ANIMDATA]; +extern Common::Array<AnimData> animDataTable; void freeAnimDataTable(void); void freeAnimDataRange(byte startIdx, byte numIdx); diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp index 900f1678db..ab1f5ac5e9 100644 --- a/engines/cine/cine.cpp +++ b/engines/cine/cine.cpp @@ -128,6 +128,10 @@ void CineEngine::initialize() { objectTable.resize(NUM_MAX_OBJECT); resetObjectTable(); + // Resize animation data table to its correct size and reset all its elements + animDataTable.resize(NUM_MAX_ANIMDATA); + freeAnimDataTable(); + _timerDelayMultiplier = 12; // Set default speed setupOpcodes(); diff --git a/engines/cine/gfx.cpp b/engines/cine/gfx.cpp index 1da4a91d7f..c6c5faf464 100644 --- a/engines/cine/gfx.cpp +++ b/engines/cine/gfx.cpp @@ -436,7 +436,7 @@ void FWRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { switch (it->type) { // color sprite case 0: - sprite = animDataTable + objectTable[it->objIdx].frame; + sprite = &animDataTable[objectTable[it->objIdx].frame]; len = sprite->_realWidth * sprite->_height; mask = new byte[len]; memcpy(mask, sprite->mask(), len); @@ -1074,7 +1074,7 @@ void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { if (objectTable[it->objIdx].frame < 0) { break; } - sprite = animDataTable + objectTable[it->objIdx].frame; + sprite = &animDataTable[objectTable[it->objIdx].frame]; len = sprite->_realWidth * sprite->_height; mask = new byte[len]; generateMask(sprite->data(), mask, len, objectTable[it->objIdx].part); @@ -1108,7 +1108,7 @@ void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { assert(it->objIdx < NUM_MAX_OBJECT); var5 = it->x; // A global variable updated here! obj = &objectTable[it->objIdx]; - sprite = animDataTable + obj->frame; + sprite = &animDataTable[obj->frame]; if (obj->frame < 0 || it->x < 0 || it->x > 8 || !_bgTable[it->x].bg || sprite->_bpp != 1) { break; |