(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

This commit is contained in:
rubidium
2013-11-24 19:46:16 +00:00
parent 4e34aae523
commit 30a390b759
2 changed files with 6 additions and 2 deletions

View File

@@ -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;