1
0
Fork 0

Fix #6564: enforce types of arguments for station name strings (#7419)

pull/7489/head
glx22 2019-03-26 22:50:56 +01:00 committed by PeterN
parent 1f39a31eb7
commit 6bfec89fcf
1 changed files with 7 additions and 3 deletions

View File

@ -78,7 +78,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++];
@ -1416,8 +1419,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;