diff options
author | Paul Gilbert | 2018-04-01 22:35:14 -0400 |
---|---|---|
committer | Paul Gilbert | 2018-04-01 22:35:14 -0400 |
commit | 0cde83ea01cfa1bfd3253bcfa3a7af0b7af5ad02 (patch) | |
tree | 66249b8aa425e624c57bab1085eccd4ac4731bad | |
parent | 388f55b85791a5a5c9666c7429e27532dfd41d3c (diff) | |
download | scummvm-rg350-0cde83ea01cfa1bfd3253bcfa3a7af0b7af5ad02.tar.gz scummvm-rg350-0cde83ea01cfa1bfd3253bcfa3a7af0b7af5ad02.tar.bz2 scummvm-rg350-0cde83ea01cfa1bfd3253bcfa3a7af0b7af5ad02.zip |
XEEN: Fix Coverity reported overruns
-rw-r--r-- | engines/xeen/dialogs/dialogs_quests.cpp | 7 | ||||
-rw-r--r-- | engines/xeen/item.cpp | 5 | ||||
-rw-r--r-- | engines/xeen/party.h | 1 | ||||
-rw-r--r-- | engines/xeen/resources.h | 2 |
4 files changed, 11 insertions, 4 deletions
diff --git a/engines/xeen/dialogs/dialogs_quests.cpp b/engines/xeen/dialogs/dialogs_quests.cpp index 8f8ebe785d..239793ee8c 100644 --- a/engines/xeen/dialogs/dialogs_quests.cpp +++ b/engines/xeen/dialogs/dialogs_quests.cpp @@ -45,6 +45,7 @@ void Quests::execute() { bool headerShown = false; int topRow = 0; const char **questItems = (g_vm->getGameID() == GType_Swords) ? Res.QUEST_ITEM_NAMES_SWORDS : Res.QUEST_ITEM_NAMES; + int itemsCount = (g_vm->getGameID() == GType_Swords) ? TOTAL_QUEST_ITEMS_SWORDS : TOTAL_QUEST_ITEMS; addButtons(); loadQuestNotes(); @@ -67,12 +68,12 @@ void Quests::execute() { switch (mode) { case QUEST_ITEMS: - for (int idx = 0; idx < TOTAL_QUEST_ITEMS; ++idx) + for (int idx = 0; idx < itemsCount; ++idx) lines[idx] = "\b \b*"; count = 0; headerShown = false; - for (int idx = 0; idx < TOTAL_QUEST_ITEMS; ++idx) { + for (int idx = 0; idx < itemsCount; ++idx) { if (party._questItems[idx]) { if (!count && !headerShown && idx < 35) { lines[count++] = Res.CLOUDS_OF_XEEN_LINE; @@ -116,7 +117,7 @@ void Quests::execute() { break; case CURRENT_QUESTS: - for (int idx = 0; idx < TOTAL_QUEST_ITEMS; ++idx) + for (int idx = 0; idx < itemsCount; ++idx) lines[idx] = ""; count = 0; diff --git a/engines/xeen/item.cpp b/engines/xeen/item.cpp index a85f5ab3b8..6a37fa1d92 100644 --- a/engines/xeen/item.cpp +++ b/engines/xeen/item.cpp @@ -89,12 +89,16 @@ const char *XeenItem::getItemName(ItemCategory category, uint id) { if (id < 82) { switch (category) { case CATEGORY_WEAPON: + assert(id < 41); return Res.WEAPON_NAMES[id]; case CATEGORY_ARMOR: + assert(id < 14); return Res.ARMOR_NAMES[id]; case CATEGORY_ACCESSORY: + assert(id < 11); return Res.ACCESSORY_NAMES[id]; default: + assert(id < 22); return Res.MISC_NAMES[id]; } } else { @@ -108,6 +112,7 @@ const char *XeenItem::getItemName(ItemCategory category, uint id) { case CATEGORY_ACCESSORY: return questItems[id - 82 + 35 + 14]; default: + assert(g_vm->getGameID() != GType_Swords); return questItems[id - 82 + 35 + 14 + 11]; } } diff --git a/engines/xeen/party.h b/engines/xeen/party.h index ef3a67ff62..b0be1a2f21 100644 --- a/engines/xeen/party.h +++ b/engines/xeen/party.h @@ -53,6 +53,7 @@ enum PartyBank { #define MAX_PARTY_COUNT 8 #define TOTAL_STATS 7 #define TOTAL_QUEST_ITEMS 85 +#define TOTAL_QUEST_ITEMS_SWORDS 51 #define TOTAL_QUEST_FLAGS 56 #define MAX_TREASURE_ITEMS 10 diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h index 007aaa3a75..bfd5cce41b 100644 --- a/engines/xeen/resources.h +++ b/engines/xeen/resources.h @@ -306,7 +306,7 @@ public: const char *ITEM_CURSED; const char *ITEM_OF; const char *BONUS_NAMES[7]; - const char *WEAPON_NAMES[35]; + const char *WEAPON_NAMES[41]; const char *ARMOR_NAMES[14]; const char *ACCESSORY_NAMES[11]; const char *MISC_NAMES[22]; |