AVALANCHE: Fix a couple of (theoretical) out of bounds accesses (CID 1109650)

This commit is contained in:
Strangerke 2013-10-24 07:56:32 +02:00
parent b64e621883
commit 0b4baa6873
3 changed files with 12 additions and 7 deletions

View file

@ -1229,7 +1229,7 @@ void AvalancheEngine::checkClick() {
_parser->_thing += 49; _parser->_thing += 49;
_parser->_person = kPeoplePardon; _parser->_person = kPeoplePardon;
} else { } else {
_parser->_person = (People) _thinks; _parser->_person = (People)_thinks;
_parser->_thing = _parser->kPardon; _parser->_thing = _parser->kPardon;
} }
callVerb(kVerbCodeExam); callVerb(kVerbCodeExam);

View file

@ -1015,10 +1015,13 @@ bool Parser::isHolding() {
if (_thing > 100) if (_thing > 100)
_vm->_dialogs->displayText("Be reasonable!"); _vm->_dialogs->displayText("Be reasonable!");
else if (!_vm->_objects[_thing - 1]) else if (_thing <= kObjectNum) {
// Verbs that need "_thing" to be in the inventory. if (!_vm->_objects[_thing - 1])
_vm->_dialogs->displayText("You're not holding it, Avvy."); // Verbs that need "_thing" to be in the inventory.
else _vm->_dialogs->displayText("You're not holding it, Avvy.");
else
holdingResult = true;
} else
holdingResult = true; holdingResult = true;
return holdingResult; return holdingResult;
@ -1053,8 +1056,10 @@ void Parser::examine() {
examineObject(); examineObject();
else if ((50 <= _thing) && (_thing <= 100)) { else if ((50 <= _thing) && (_thing <= 100)) {
// Also _thing // Also _thing
int id = _thing - 50;
assert(id < 31);
openBox(true); openBox(true);
_vm->_dialogs->displayText(*_vm->_also[_thing - 50][1]); _vm->_dialogs->displayText(*_vm->_also[id][1]);
openBox(false); openBox(false);
} }
} }

View file

@ -66,7 +66,7 @@ public:
Common::String _inputText; // Original name: current Common::String _inputText; // Original name: current
Common::String _inputTextBackup; Common::String _inputTextBackup;
byte _inputTextPos; // Original name: curpos byte _inputTextPos; // Original name: curpos
bool _quote; // 66 or 99 next? bool _quote;
bool _cursorState; bool _cursorState;
bool _weirdWord; bool _weirdWord;