diff options
author | glx22 <glx22@users.noreply.github.com> | 2019-03-26 22:50:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-26 22:50:56 +0100 |
commit | 427d9d483fcd7e3c8dae8e9c84832c9e6bb34b50 (patch) | |
tree | b9161feebeaa206181098b6f9a02023bc5d05979 /src/strings.cpp | |
parent | a065d4623e0f3dc507125aea688b120b02ed4e1b (diff) | |
download | openttd-427d9d483fcd7e3c8dae8e9c84832c9e6bb34b50.tar.xz |
Fix #6564: enforce types of arguments for station name strings (#7419)
Diffstat (limited to 'src/strings.cpp')
-rw-r--r-- | src/strings.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/strings.cpp b/src/strings.cpp index c3669e5dc..be45a098b 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -76,7 +76,10 @@ int64 StringParameters::GetInt64(WChar type) return 0; } if (this->type != NULL) { - assert(this->type[this->offset] == 0 || this->type[this->offset] == type); + if (this->type[this->offset] != 0 && this->type[this->offset] != type) { + DEBUG(misc, 0, "Trying to read string parameter with wrong type"); + return 0; + } this->type[this->offset] = type; } return this->data[this->offset++]; @@ -1415,8 +1418,9 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg } } - int64 args_array[] = {STR_TOWN_NAME, st->town->index, st->index}; - StringParameters tmp_params(args_array); + uint64 args_array[] = {STR_TOWN_NAME, st->town->index, st->index}; + WChar types_array[] = {0, SCC_TOWN_NAME, SCC_NUM}; + StringParameters tmp_params(args_array, 3, types_array); buff = GetStringWithArgs(buff, str, &tmp_params, last); } break; |