diff options
author | rubidium <rubidium@openttd.org> | 2013-11-24 19:46:16 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2013-11-24 19:46:16 +0000 |
commit | 168fa4129d9d3b1296be8684f0f2f9c146014456 (patch) | |
tree | 1fd20ec9934dc05bba1ff8ef6bd683231a95189d /src/script | |
parent | 4de2871fc0e71fd07824bbe63c12d83af9e0ca12 (diff) | |
download | openttd-168fa4129d9d3b1296be8684f0f2f9c146014456.tar.xz |
(svn r26092) -Fix [FS#5818]: prevent scripts from crashing OpenTTD when they send text with command codes to user editable texts such as sign and station names
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/api/script_object.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/script/api/script_object.cpp b/src/script/api/script_object.cpp index 6d4140b2a..d9aefca3c 100644 --- a/src/script/api/script_object.cpp +++ b/src/script/api/script_object.cpp @@ -287,7 +287,11 @@ ScriptObject::ActiveInstance::~ActiveInstance() return false; } - assert(StrEmpty(text) || (GetCommandFlags(cmd) & CMD_STR_CTRL) != 0 || StrValid(text, text + strlen(text))); + if (!StrEmpty(text) && (GetCommandFlags(cmd) & CMD_STR_CTRL) == 0) { + /* The string must be valid, i.e. not contain special codes. Since some + * can be made with GSText, make sure the control codes are removed. */ + str_validate(text, text + strlen(text)), SVS_NONE); + } /* Set the default callback to return a true/false result of the DoCommand */ if (callback == NULL) callback = &ScriptInstance::DoCommandReturn; |