Skip to content

Commit

Permalink
Fix: when a string consumes more parameters than allowed, nullptr is …
Browse files Browse the repository at this point in the history
…attempted to be formatted
  • Loading branch information
rubidium42 committed Jun 13, 2023
1 parent f1ec2f2 commit 1146904
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1146904

Please sign in to comment.