aboutsummaryrefslogtreecommitdiff
path: root/engines/tsage/ringworld2
diff options
context:
space:
mode:
authorD G Turner2014-06-08 17:00:14 +0100
committerD G Turner2014-06-08 17:00:14 +0100
commit06b01b8920ec36b31fe9bb758a75bbaf9809686d (patch)
tree1095db2697d3665003b89446dc00129e55c414b3 /engines/tsage/ringworld2
parent386596ca9670ce159a6c07811b739ba73376abcf (diff)
downloadscummvm-rg350-06b01b8920ec36b31fe9bb758a75bbaf9809686d.tar.gz
scummvm-rg350-06b01b8920ec36b31fe9bb758a75bbaf9809686d.tar.bz2
scummvm-rg350-06b01b8920ec36b31fe9bb758a75bbaf9809686d.zip
TSAGE: R2R - Correct possible out of range accesses checks.
These had an off-by-one error in the upper bound check. This should fix the remaining warnings reported as bug #6621.
Diffstat (limited to 'engines/tsage/ringworld2')
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes1.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.cpp b/engines/tsage/ringworld2/ringworld2_scenes1.cpp
index b36b18575b..29646d1612 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes1.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes1.cpp
@@ -4931,8 +4931,8 @@ int Scene1337::getPreventionCardId(int cardId) {
}
bool Scene1337::isAttackPossible(int victimId, int cardId) {
- if (victimId < 0 || victimId > ARRAYSIZE(_gameBoardSide))
- error("Scene1337::isAttackPossible() victimId:%d out of range 0 to %d", victimId, ARRAYSIZE(_gameBoardSide));
+ if (victimId < 0 || victimId >= ARRAYSIZE(_gameBoardSide))
+ error("Scene1337::isAttackPossible() victimId:%d out of range 0 to %d", victimId, ARRAYSIZE(_gameBoardSide)-1);
for (int i = 0; i <= 7; i++) {
if (_gameBoardSide[victimId]._outpostStation[i]._cardId != 0) {
@@ -5982,16 +5982,16 @@ void Scene1337::handlePlayer1() {
for (int j = 0; j <= 3; j++) {
//CHECKME: tmpVal or rndVal?
// FIXME: This is probably meant to be rndVal, but not clear...
- if (tmpVal < 0 || tmpVal > ARRAYSIZE(_gameBoardSide))
- error("Scene1337::handlePlayer1() tmpVal:%d out of range 0 to %d", tmpVal, ARRAYSIZE(_gameBoardSide));
+ if (tmpVal < 0 || tmpVal >= ARRAYSIZE(_gameBoardSide))
+ error("Scene1337::handlePlayer1() tmpVal:%d out of range 0 to %d", tmpVal, ARRAYSIZE(_gameBoardSide)-1);
if (tmpVal != 1) {
if ((_gameBoardSide[tmpVal]._delayCard._cardId == 0) && isAttackPossible(tmpVal, _gameBoardSide[1]._handCard[i]._cardId))
count = tmpVal;
}
- if (count < 0 || count > ARRAYSIZE(_gameBoardSide))
- error("Scene1337::handlePlayer1() count:%d out of range 0 to %d", count, ARRAYSIZE(_gameBoardSide));
+ if (count < 0 || count >= ARRAYSIZE(_gameBoardSide))
+ error("Scene1337::handlePlayer1() count:%d out of range 0 to %d", count, ARRAYSIZE(_gameBoardSide)-1);
if (count != -1) {
playDelayCard(&_gameBoardSide[1]._handCard[i], &_gameBoardSide[count]._delayCard);