aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorrichiesams2013-08-05 00:00:21 -0500
committerrichiesams2013-08-05 00:05:25 -0500
commit4b0015b8e997e9ca95141216f2b24ee33df01055 (patch)
tree1c732c9551e67c4932b50ee50d6185868a510d96 /engines
parent1d694dcb81604c20a8755f80d509eccb8904017e (diff)
downloadscummvm-rg350-4b0015b8e997e9ca95141216f2b24ee33df01055.tar.gz
scummvm-rg350-4b0015b8e997e9ca95141216f2b24ee33df01055.tar.bz2
scummvm-rg350-4b0015b8e997e9ca95141216f2b24ee33df01055.zip
ZVISION: Check if a key exists before returning _globalState value.
operator[] creates a key value pair if it doesn't exist. So blindly returning a value without checking if the key exists could result in undefined behavior, depening on what the value is initialized to in its constructor
Diffstat (limited to 'engines')
-rw-r--r--engines/zvision/script_manager.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 2e57c18a3e..7fcade22c1 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -118,7 +118,10 @@ void ScriptManager::checkPuzzleCriteria() {
}
uint ScriptManager::getStateValue(uint32 key) {
- return _globalState[key];
+ if (_globalState.contains(key))
+ return _globalState[key];
+ else
+ return 0;
}
void ScriptManager::setStateValue(uint32 key, uint value) {