mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 05:38:56 +00:00
Properly guarding Script::getOffset() and adding a reverse operation
svn-id: r41782
This commit is contained in:
parent
4ab4517016
commit
c31b79b7c9
@ -94,8 +94,7 @@ byte *Expression::decodePtr(int32 n) {
|
||||
|
||||
switch (n >> 28) {
|
||||
case kExecPtr:
|
||||
ptr = _vm->_game->_script->getData();
|
||||
break;
|
||||
return _vm->_game->_script->getData((n & 0x0FFFFFFF));
|
||||
case kInterVar:
|
||||
ptr = (byte *) _vm->_inter->_variables->getAddressOff8(0);
|
||||
break;
|
||||
|
@ -123,9 +123,21 @@ int32 Script::getOffset(byte *ptr) {
|
||||
if (!_totData)
|
||||
return -1;
|
||||
|
||||
if ((ptr < _totData) || (ptr >= (_totData + _totSize)))
|
||||
return -1;
|
||||
|
||||
return ptr - _totData;
|
||||
}
|
||||
|
||||
byte *Script::getData(int32 offset) {
|
||||
if (!_totData)
|
||||
return 0;
|
||||
if ((offset < 0) || (((uint32) offset) >= _totSize))
|
||||
return 0;
|
||||
|
||||
return _totData + offset;
|
||||
}
|
||||
|
||||
byte *Script::getData() {
|
||||
return _totData;
|
||||
}
|
||||
|
@ -90,6 +90,9 @@ public:
|
||||
|
||||
/** Returns the offset the specified pointer is within the script data. */
|
||||
int32 getOffset(byte *ptr);
|
||||
/** Returns the data pointer to the offset. */
|
||||
byte *getData(int32 offset);
|
||||
|
||||
/** Returns the raw data pointer. */
|
||||
byte *getData();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user