Skip to content

Commit

Permalink
WINTERMUTE: Guard ConfMan a bit better.
Browse files Browse the repository at this point in the history
  • Loading branch information
somaen committed Jan 22, 2013
1 parent 472f722 commit d322592
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions engines/wintermute/base/base_game.cpp
Expand Up @@ -1258,7 +1258,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->correctParams(2);
const char *key = stack->pop()->getString();
const char *val = stack->pop()->getString();
Common::String privKey = "priv_" + StringUtil::encodeSetting(key);
Common::String privKey = "wme_" + StringUtil::encodeSetting(key);
Common::String privVal = StringUtil::encodeSetting(val);
ConfMan.set(privKey, privVal);
stack->pushNULL();
Expand All @@ -1272,7 +1272,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->correctParams(2);
const char *key = stack->pop()->getString();
const char *initVal = stack->pop()->getString();
Common::String privKey = "priv_" + StringUtil::encodeSetting(key);
Common::String privKey = "wme_" + StringUtil::encodeSetting(key);
Common::String result = initVal;
if (ConfMan.hasKey(privKey)) {
result = StringUtil::decodeSetting(ConfMan.get(key));
Expand Down
6 changes: 4 additions & 2 deletions engines/wintermute/utils/string_util.cpp
Expand Up @@ -213,8 +213,10 @@ int StringUtil::indexOf(const WideString &str, const WideString &toFind, size_t
}

Common::String StringUtil::encodeSetting(const Common::String &str) {
if (str.contains('=')) {
error("Setting contains '='");
for (int i = 0; i < str.size(); i++) {
if ((str[i] < 33) || (str[i] == '=') || (str[i] > 126)) {
error("Setting contains illegal characters: %s", str.c_str());
}
}
return str;
}
Expand Down

0 comments on commit d322592

Please sign in to comment.