aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock/journal.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2015-12-09 21:44:08 -0500
committerPaul Gilbert2015-12-09 21:44:08 -0500
commitc8acaff52146e6b88cd82c344252c14faf985ba9 (patch)
tree54d15e7a896bdb9c515048d04e8fee8c19969dd2 /engines/sherlock/journal.cpp
parent4a3160d8c142e49295db2179d801eee21f5f6199 (diff)
downloadscummvm-rg350-c8acaff52146e6b88cd82c344252c14faf985ba9.tar.gz
scummvm-rg350-c8acaff52146e6b88cd82c344252c14faf985ba9.tar.bz2
scummvm-rg350-c8acaff52146e6b88cd82c344252c14faf985ba9.zip
SHERLOCK: Add validation for journal entry values
Diffstat (limited to 'engines/sherlock/journal.cpp')
-rw-r--r--engines/sherlock/journal.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/engines/sherlock/journal.cpp b/engines/sherlock/journal.cpp
index e443b6f727..c4aaa07a73 100644
--- a/engines/sherlock/journal.cpp
+++ b/engines/sherlock/journal.cpp
@@ -715,6 +715,15 @@ void Journal::record(int converseNum, int statementNum, bool replyOnly) {
return;
}
+ // Do a bit of validation here
+ assert(converseNum >= 0 && converseNum < (int)_directory.size());
+ const Common::String &dirFilename = _directory[converseNum];
+ Common::String locStr(dirFilename.c_str() + 4, dirFilename.c_str() + 6);
+ int newLocation = atoi(locStr.c_str());
+ assert(newLocation >= 1 && newLocation <= (int)_locations.size());
+ assert(!_locations[newLocation - 1].empty());
+ assert(statementNum >= 0 && statementNum < (int)_vm->_talk->_statements.size());
+
// Record the entry into the list
_journal.push_back(JournalEntry(converseNum, statementNum, replyOnly));
_index = _journal.size() - 1;
@@ -726,7 +735,7 @@ void Journal::record(int converseNum, int statementNum, bool replyOnly) {
_index = saveIndex;
_sub = saveSub;
- // If new lines were added to the ournal, update the total number of lines
+ // If new lines were added to the journal, update the total number of lines
// the journal continues
if (!_lines.empty()) {
_maxPage += _lines.size();