diff options
author | Littleboy | 2014-06-11 23:35:57 -0400 |
---|---|---|
committer | Littleboy | 2014-06-16 18:46:32 -0400 |
commit | ae12264c5f8e4aa5eb7422f1b4719846f758e14b (patch) | |
tree | 63d88b391d8f2841e70a9d6ef1af2e258cc8c15f /engines | |
parent | 94861cd73c400ac95b6af951db8050f9dce81c04 (diff) | |
download | scummvm-rg350-ae12264c5f8e4aa5eb7422f1b4719846f758e14b.tar.gz scummvm-rg350-ae12264c5f8e4aa5eb7422f1b4719846f758e14b.tar.bz2 scummvm-rg350-ae12264c5f8e4aa5eb7422f1b4719846f758e14b.zip |
LASTEXPRESS: Fix potential out-of-bounds read. CID 1003992
Diffstat (limited to 'engines')
-rw-r--r-- | engines/lastexpress/game/inventory.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/engines/lastexpress/game/inventory.cpp b/engines/lastexpress/game/inventory.cpp index 9e02b3bc1d..622d547542 100644 --- a/engines/lastexpress/game/inventory.cpp +++ b/engines/lastexpress/game/inventory.cpp @@ -40,7 +40,6 @@ #include "lastexpress/lastexpress.h" #include "lastexpress/resource.h" - namespace LastExpress { Inventory::Inventory(LastExpressEngine *engine) : _engine(engine), _selectedItem(kItemNone), _highlightedItemIndex(0), _itemsShown(0), @@ -534,18 +533,18 @@ Common::String Inventory::toString() { // Private methods ////////////////////////////////////////////////////////////////////////// InventoryItem Inventory::getFirstExaminableItem() const { - int index = 0; - InventoryEntry entry = _entries[index]; - while (!entry.inPocket || !entry.cursor || entry.floating) { - index++; - entry = _entries[index]; + do { + InventoryEntry entry = _entries[index]; - if (index >= kPortraitOriginal) - return kItemNone; - } + // Check if it is an examinable item + if (entry.inPocket && entry.cursor && !entry.floating) + return (InventoryItem)index; + + index++; + } while (index < kPortraitOriginal); - return (InventoryItem)index; + return kItemNone; } bool Inventory::isItemSceneParameter(InventoryItem item) const { |