[Scummvm-cvs-logs] SF.net SVN: scummvm:[41782] scummvm/trunk/engines/gob
drmccoy at users.sourceforge.net
drmccoy at users.sourceforge.net
Mon Jun 22 22:51:34 CEST 2009
Revision: 41782
http://scummvm.svn.sourceforge.net/scummvm/?rev=41782&view=rev
Author: drmccoy
Date: 2009-06-22 20:51:34 +0000 (Mon, 22 Jun 2009)
Log Message:
-----------
Properly guarding Script::getOffset() and adding a reverse operation
Modified Paths:
--------------
scummvm/trunk/engines/gob/expression.cpp
scummvm/trunk/engines/gob/script.cpp
scummvm/trunk/engines/gob/script.h
Modified: scummvm/trunk/engines/gob/expression.cpp
===================================================================
--- scummvm/trunk/engines/gob/expression.cpp 2009-06-22 20:27:47 UTC (rev 41781)
+++ scummvm/trunk/engines/gob/expression.cpp 2009-06-22 20:51:34 UTC (rev 41782)
@@ -94,8 +94,7 @@
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;
Modified: scummvm/trunk/engines/gob/script.cpp
===================================================================
--- scummvm/trunk/engines/gob/script.cpp 2009-06-22 20:27:47 UTC (rev 41781)
+++ scummvm/trunk/engines/gob/script.cpp 2009-06-22 20:51:34 UTC (rev 41782)
@@ -123,9 +123,21 @@
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;
}
Modified: scummvm/trunk/engines/gob/script.h
===================================================================
--- scummvm/trunk/engines/gob/script.h 2009-06-22 20:27:47 UTC (rev 41781)
+++ scummvm/trunk/engines/gob/script.h 2009-06-22 20:51:34 UTC (rev 41782)
@@ -90,6 +90,9 @@
/** 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();
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