[Scummvm-cvs-logs] scummvm master -> 2d70a7af6ddbec99c87ed3885596b4b964cc58b1
m-kiewitz
m_kiewitz at users.sourceforge.net
Sun Jun 14 18:15:13 CEST 2015
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
2d70a7af6d SHERLOCK: add boundary checks to fixed text class
Commit: 2d70a7af6ddbec99c87ed3885596b4b964cc58b1
https://github.com/scummvm/scummvm/commit/2d70a7af6ddbec99c87ed3885596b4b964cc58b1
Author: Martin Kiewitz (m_kiewitz at users.sourceforge.net)
Date: 2015-06-14T18:14:52+02:00
Commit Message:
SHERLOCK: add boundary checks to fixed text class
for action strings
Changed paths:
engines/sherlock/fixed_text.cpp
engines/sherlock/fixed_text.h
diff --git a/engines/sherlock/fixed_text.cpp b/engines/sherlock/fixed_text.cpp
index 7594fc8..2e0ae4a 100644
--- a/engines/sherlock/fixed_text.cpp
+++ b/engines/sherlock/fixed_text.cpp
@@ -250,28 +250,31 @@ static const Common::String fixedTextES_ActionUse[] = {
"Las puertas no fuman"
};
+#define FIXEDTEXT_GETCOUNT(_name_) sizeof(_name_) / sizeof(Common::String)
+#define FIXEDTEXT_ENTRY(_name_) _name_, FIXEDTEXT_GETCOUNT(_name_)
+
static const FixedTextActionEntry fixedTextEN_Actions[] = {
- { fixedTextEN_ActionOpen },
- { fixedTextEN_ActionClose },
- { fixedTextEN_ActionMove },
- { fixedTextEN_ActionPick },
- { fixedTextEN_ActionUse }
+ { FIXEDTEXT_ENTRY(fixedTextEN_ActionOpen) },
+ { FIXEDTEXT_ENTRY(fixedTextEN_ActionClose) },
+ { FIXEDTEXT_ENTRY(fixedTextEN_ActionMove) },
+ { FIXEDTEXT_ENTRY(fixedTextEN_ActionPick) },
+ { FIXEDTEXT_ENTRY(fixedTextEN_ActionUse) }
};
static const FixedTextActionEntry fixedTextDE_Actions[] = {
- { fixedTextDE_ActionOpen },
- { fixedTextDE_ActionClose },
- { fixedTextDE_ActionMove },
- { fixedTextDE_ActionPick },
- { fixedTextDE_ActionUse }
+ { FIXEDTEXT_ENTRY(fixedTextDE_ActionOpen) },
+ { FIXEDTEXT_ENTRY(fixedTextDE_ActionClose) },
+ { FIXEDTEXT_ENTRY(fixedTextDE_ActionMove) },
+ { FIXEDTEXT_ENTRY(fixedTextDE_ActionPick) },
+ { FIXEDTEXT_ENTRY(fixedTextDE_ActionUse) }
};
static const FixedTextActionEntry fixedTextES_Actions[] = {
- { fixedTextES_ActionOpen },
- { fixedTextES_ActionClose },
- { fixedTextES_ActionMove },
- { fixedTextES_ActionPick },
- { fixedTextES_ActionUse }
+ { FIXEDTEXT_ENTRY(fixedTextES_ActionOpen) },
+ { FIXEDTEXT_ENTRY(fixedTextES_ActionClose) },
+ { FIXEDTEXT_ENTRY(fixedTextES_ActionMove) },
+ { FIXEDTEXT_ENTRY(fixedTextES_ActionPick) },
+ { FIXEDTEXT_ENTRY(fixedTextES_ActionUse) }
};
// =========================================
@@ -307,7 +310,11 @@ const Common::String FixedText::getText(FixedTextId fixedTextId) {
const Common::String FixedText::getActionMessage(FixedTextActionId actionId, int messageIndex) {
assert(actionId >= 0);
- return _curLanguageEntry->actionArray[actionId].fixedTextArray[messageIndex];
+ assert(messageIndex >= 0);
+ const FixedTextActionEntry *curActionEntry = &_curLanguageEntry->actionArray[actionId];
+
+ assert(messageIndex < curActionEntry->fixedTextArrayCount);
+ return curActionEntry->fixedTextArray[messageIndex];
}
} // End of namespace Sherlock
diff --git a/engines/sherlock/fixed_text.h b/engines/sherlock/fixed_text.h
index 7c4a7a8..e6a8507 100644
--- a/engines/sherlock/fixed_text.h
+++ b/engines/sherlock/fixed_text.h
@@ -69,6 +69,7 @@ enum FixedTextActionId {
struct FixedTextActionEntry {
const Common::String *fixedTextArray;
+ int fixedTextArrayCount;
};
struct FixedTextLanguageEntry {
More information about the Scummvm-git-logs
mailing list