From 1b6ac1a67cc65ca5fcb5c076f3f48b7ce8c6e6a8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 15 Jun 2019 15:47:32 -0700 Subject: GLK: ADVSYS: Fix variable range checks --- engines/glk/advsys/game.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'engines/glk/advsys') diff --git a/engines/glk/advsys/game.cpp b/engines/glk/advsys/game.cpp index 3b6133d6ef..d051a352b6 100644 --- a/engines/glk/advsys/game.cpp +++ b/engines/glk/advsys/game.cpp @@ -250,12 +250,16 @@ int Game::getActionLocation(int action) const { } int Game::getVariable(int variableNum) { - assert(variableNum < _variableCount); + if (variableNum < 1 || variableNum > _variableCount) + error("Invalid ariable number %d", variableNum); + return READ_LE_UINT16(_variableTable + variableNum * 2); } void Game::setVariable(int variableNum, int value) { - assert(variableNum < _variableCount); + if (variableNum < 1 || variableNum > _variableCount) + error("Invalid ariable number %d", variableNum); + WRITE_LE_UINT16(_variableTable + variableNum * 2, value); } -- cgit v1.2.3