diff options
author | D G Turner | 2014-06-08 03:12:07 +0100 |
---|---|---|
committer | D G Turner | 2014-06-08 03:12:07 +0100 |
commit | 560812bd5e46240c3a9ec074a11ba9169e95ce19 (patch) | |
tree | 275bedad557f214102aa0c4bfa8074866f9f6d6a | |
parent | ee894cfc4af8aa4a69eaf4bdd62ce604d5468c15 (diff) | |
download | scummvm-rg350-560812bd5e46240c3a9ec074a11ba9169e95ce19.tar.gz scummvm-rg350-560812bd5e46240c3a9ec074a11ba9169e95ce19.tar.bz2 scummvm-rg350-560812bd5e46240c3a9ec074a11ba9169e95ce19.zip |
TSAGE: R2R - Error out on possible out of range accesses.
This will fix the warnings reported as bug #6621.
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_scenes1.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.cpp b/engines/tsage/ringworld2/ringworld2_scenes1.cpp index 110c3ff510..b36b18575b 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes1.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes1.cpp @@ -4931,6 +4931,9 @@ 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)); + for (int i = 0; i <= 7; i++) { if (_gameBoardSide[victimId]._outpostStation[i]._cardId != 0) { if (getPreventionCardId(cardId) == _gameBoardSide[victimId]._outpostStation[i]._cardId) @@ -5978,11 +5981,18 @@ 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 != 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 != -1) { playDelayCard(&_gameBoardSide[1]._handCard[i], &_gameBoardSide[count]._delayCard); return; |