1
0
Fork 0

Fix: when a string consumes more parameters than allowed, nullptr is attempted to be formatted

pull/11004/head
Rubidium 2023-06-13 19:30:03 +02:00 committed by rubidium42
parent f1ec2f274c
commit 1146904d45
1 changed files with 3 additions and 1 deletions

View File

@ -1074,7 +1074,9 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara
case SCC_RAW_STRING_POINTER: { // {RAW_STRING}
const char *raw_string = (const char *)(size_t)args->GetInt64(SCC_RAW_STRING_POINTER);
if (game_script && std::find(_game_script_raw_strings.begin(), _game_script_raw_strings.end(), raw_string) == _game_script_raw_strings.end()) {
/* raw_string can be(come) nullptr when the parameter is out of range and 0 is returned instead. */
if (raw_string == nullptr ||
(game_script && std::find(_game_script_raw_strings.begin(), _game_script_raw_strings.end(), raw_string) == _game_script_raw_strings.end())) {
builder += "(invalid RAW_STRING parameter)";
break;
}