aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen
diff options
context:
space:
mode:
authorPeter Helbing2019-06-07 22:19:06 +0200
committerPaul Gilbert2019-06-09 14:17:23 -0700
commit7c95deb5b6f1311fb34c095fc4df3c979a893f50 (patch)
tree8eb21ac3c9d2c5faf40a5c60e0162baed2670ab4 /engines/xeen
parentf2b8dc4776f0b7c4eabf26b31c5675ccb81e561e (diff)
downloadscummvm-rg350-7c95deb5b6f1311fb34c095fc4df3c979a893f50.tar.gz
scummvm-rg350-7c95deb5b6f1311fb34c095fc4df3c979a893f50.tar.bz2
scummvm-rg350-7c95deb5b6f1311fb34c095fc4df3c979a893f50.zip
XEEN: Check bounds of stat values array, bug #10971
Diffstat (limited to 'engines/xeen')
-rw-r--r--engines/xeen/character.cpp5
-rw-r--r--engines/xeen/dialogs/dialogs_char_info.cpp6
2 files changed, 6 insertions, 5 deletions
diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp
index afc013ba89..47ef0b8ecd 100644
--- a/engines/xeen/character.cpp
+++ b/engines/xeen/character.cpp
@@ -418,8 +418,9 @@ int Character::statColor(int amount, int threshold) {
int Character::statBonus(uint statValue) const {
int idx;
- for (idx = 0; Res.STAT_VALUES[idx] <= (int)statValue; ++idx)
- ;
+ for (idx = 0; idx < ARRAYSIZE(Res.STAT_VALUES) - 1; ++idx)
+ if (Res.STAT_VALUES[idx] > (int)statValue)
+ break;
return Res.STAT_BONUSES[idx];
}
diff --git a/engines/xeen/dialogs/dialogs_char_info.cpp b/engines/xeen/dialogs/dialogs_char_info.cpp
index aec8be5ee4..3923caf172 100644
--- a/engines/xeen/dialogs/dialogs_char_info.cpp
+++ b/engines/xeen/dialogs/dialogs_char_info.cpp
@@ -359,9 +359,9 @@ bool CharacterInfo::expandStat(int attrib, const Character &c) {
// Basic attributes
stat1 = c.getStat((Attribute)attrib, false);
stat2 = c.getStat((Attribute)attrib, true);
- idx = 0;
- while (Res.STAT_VALUES[idx] <= (int)stat1)
- ++idx;
+ for (idx = 0; idx < ARRAYSIZE(Res.STAT_VALUES) - 1; ++idx)
+ if (Res.STAT_VALUES[idx] > (int)stat1)
+ break;
msg = Common::String::format(Res.CURRENT_MAXIMUM_RATING_TEXT, Res.STAT_NAMES[attrib],
stat1, stat2, Res.RATING_TEXT[idx]);