[Scummvm-cvs-logs] scummvm master -> 2667b502d790c640e0f6a71b21857333134b9a41
fuzzie
fuzzie at fuzzie.org
Sat Jul 2 00:07:41 CEST 2011
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
689099f9b5 MOHAWK: Fix/add bounds checking in LBCode::nextToken.
2667b502d7 MOHAWK: Add LBCode::resolveItem helper function.
Commit: 689099f9b5d93e901f4adcc24c63f7a377a33fdb
https://github.com/scummvm/scummvm/commit/689099f9b5d93e901f4adcc24c63f7a377a33fdb
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-07-01T15:03:49-07:00
Commit Message:
MOHAWK: Fix/add bounds checking in LBCode::nextToken.
Changed paths:
engines/mohawk/livingbooks_code.cpp
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index e72318d..96345ad 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -172,12 +172,8 @@ LBValue LBCode::runCode(LBItem *src, uint32 offset) {
}
void LBCode::nextToken() {
- if (_currOffset + 1 >= _size) {
- // TODO
- warning("went off the end of code");
- _currToken = kTokenEndOfFile;
- _currValue = LBValue();
- return;
+ if (_currOffset >= _size) {
+ error("went off the end of code");
}
_currToken = _data[_currOffset++];
@@ -186,6 +182,8 @@ void LBCode::nextToken() {
switch (_currToken) {
case kTokenIdentifier:
{
+ if (_currOffset + 2 > _size)
+ error("went off the end of code reading identifier");
uint16 offset = READ_BE_UINT16(_data + _currOffset);
// TODO: check string exists
_currValue = _strings[offset];
@@ -195,9 +193,13 @@ void LBCode::nextToken() {
case kTokenLiteral:
{
+ if (_currOffset + 1 > _size)
+ error("went off the end of code reading literal");
byte literalType = _data[_currOffset++];
switch (literalType) {
case kLBCodeLiteralInteger:
+ if (_currOffset + 2 > _size)
+ error("went off the end of code reading literal integer");
_currValue = READ_BE_UINT16(_data + _currOffset);
_currOffset += 2;
break;
@@ -211,6 +213,8 @@ void LBCode::nextToken() {
case kTokenConstEventId:
case 0x5e: // TODO: ??
case kTokenKeycode:
+ if (_currOffset + 2 > _size)
+ error("went off the end of code reading immediate");
_currValue = READ_BE_UINT16(_data + _currOffset);
_currOffset += 2;
break;
@@ -227,6 +231,8 @@ void LBCode::nextToken() {
case kTokenString:
{
+ if (_currOffset + 2 > _size)
+ error("went off the end of code reading string");
uint16 offset = READ_BE_UINT16(_data + _currOffset);
// TODO: check string exists
_currValue = _strings[offset];
Commit: 2667b502d790c640e0f6a71b21857333134b9a41
https://github.com/scummvm/scummvm/commit/2667b502d790c640e0f6a71b21857333134b9a41
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-07-01T15:04:24-07:00
Commit Message:
MOHAWK: Add LBCode::resolveItem helper function.
Changed paths:
engines/mohawk/livingbooks_code.cpp
engines/mohawk/livingbooks_code.h
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 96345ad..d091f95 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -555,6 +555,16 @@ void LBCode::parseMain() {
}
}
+LBItem *LBCode::resolveItem(const LBValue &value) {
+ if (value.type == kLBValueItemPtr)
+ return value.item;
+ if (value.type == kLBValueString)
+ return _vm->getItemByName(value.string);
+ if (value.type == kLBValueInteger)
+ return _vm->getItemById(value.integer);
+ return NULL;
+}
+
Common::Array<LBValue> LBCode::readParams() {
Common::Array<LBValue> params;
diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h
index 9602e2d..3e33549 100644
--- a/engines/mohawk/livingbooks_code.h
+++ b/engines/mohawk/livingbooks_code.h
@@ -206,6 +206,7 @@ protected:
void parseArithmetic2();
void parseMain();
+ LBItem *resolveItem(const LBValue &value);
Common::Array<LBValue> readParams();
Common::Rect getRectFromParams(const Common::Array<LBValue> ¶ms);
More information about the Scummvm-git-logs
mailing list