aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/access/inventory.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 34470ace1e..11baa8fc08 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -87,7 +87,10 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
}
int &InventoryManager::operator[](int idx) {
- return _inv[idx]._value;
+ // WORKAROUND: At least in Amazon, some game scripts accidentally do reads
+ // beyond the length of the inventory array
+ static int invalid = 0;
+ return (idx >= _inv.size()) ? invalid : _inv[idx]._value;
}
int InventoryManager::useItem() {