aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2019-06-16 17:43:07 -0700
committerPaul Gilbert2019-06-16 17:43:07 -0700
commitfee722181079655203efb1420667f5449459aa7a (patch)
tree117c29c40b8f03bf99bb27382af407f365e95804 /engines
parent0bf2dc6d7ba8650e7070484c1cd7707d307a9137 (diff)
downloadscummvm-rg350-fee722181079655203efb1420667f5449459aa7a.tar.gz
scummvm-rg350-fee722181079655203efb1420667f5449459aa7a.tar.bz2
scummvm-rg350-fee722181079655203efb1420667f5449459aa7a.zip
GLK: ADVSYS: Fix inputs with indirect objects
Diffstat (limited to 'engines')
-rw-r--r--engines/glk/advsys/vm.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/engines/glk/advsys/vm.cpp b/engines/glk/advsys/vm.cpp
index 70b035977e..13929aed8e 100644
--- a/engines/glk/advsys/vm.cpp
+++ b/engines/glk/advsys/vm.cpp
@@ -488,7 +488,7 @@ bool VM::parseInput() {
preposition = *_wordPtr++;
// Get the indirect object
- noun2 = _adjectiveList.size();
+ noun2 = _adjectiveList.size() + 1;
for (;;) {
// Get the indirect object
if (!getNoun())
@@ -615,10 +615,15 @@ uint VM::getNoun() {
_adjectiveList.push_back(AdjectiveEntry());
assert(_adjectiveList.size() <= 20);
+ if (_wordPtr == _words.end() || getWordType(*_wordPtr) != WT_NOUN) {
+ parseError();
+ return NIL;
+ }
+
// Add a noun entry to the list
Noun n;
n._adjective = &_adjectiveList[alStart];
- n._noun = (_wordPtr == _words.end()) ? 0 : *_wordPtr++;
+ n._noun = *_wordPtr++;
n._num = _wordPtr - _words.begin() - 1;
_nouns.push_back(n);