mirror of https://github.com/OpenTTD/OpenTTD
(svn r24593) -Fix [FS#5333]: crash when a gamescript provided too many parameters to a GSText object
parent
b5a485825b
commit
2f042ea198
|
@ -62,6 +62,24 @@ void StringParameters::ClearTypeInformation()
|
||||||
MemSetT(this->type, 0, this->num_param);
|
MemSetT(this->type, 0, this->num_param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read an int64 from the argument array. The offset is increased
|
||||||
|
* so the next time GetInt64 is called the next value is read.
|
||||||
|
*/
|
||||||
|
int64 StringParameters::GetInt64(WChar type)
|
||||||
|
{
|
||||||
|
if (this->offset >= this->num_param) {
|
||||||
|
DEBUG(misc, 0, "Trying to read invalid string parameter");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (this->type != NULL) {
|
||||||
|
assert(this->type[this->offset] == 0 || this->type[this->offset] == type);
|
||||||
|
this->type[this->offset] = type;
|
||||||
|
}
|
||||||
|
return this->data[this->offset++];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shift all data in the data array by the given amount to make
|
* Shift all data in the data array by the given amount to make
|
||||||
* room for some extra parameters.
|
* room for some extra parameters.
|
||||||
|
@ -780,7 +798,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (*p != '\0') {
|
while (*p != '\0' && i < 20) {
|
||||||
uint64 param;
|
uint64 param;
|
||||||
s = ++p;
|
s = ++p;
|
||||||
|
|
||||||
|
|
|
@ -73,19 +73,7 @@ public:
|
||||||
|
|
||||||
void ClearTypeInformation();
|
void ClearTypeInformation();
|
||||||
|
|
||||||
/**
|
int64 GetInt64(WChar type = 0);
|
||||||
* Read an int64 from the argument array. The offset is increased
|
|
||||||
* so the next time GetInt64 is called the next value is read.
|
|
||||||
*/
|
|
||||||
int64 GetInt64(WChar type = 0)
|
|
||||||
{
|
|
||||||
assert(this->offset < this->num_param);
|
|
||||||
if (this->type != NULL) {
|
|
||||||
assert(this->type[this->offset] == 0 || this->type[this->offset] == type);
|
|
||||||
this->type[this->offset] = type;
|
|
||||||
}
|
|
||||||
return this->data[this->offset++];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Read an int32 from the argument array. @see GetInt64. */
|
/** Read an int32 from the argument array. @see GetInt64. */
|
||||||
int32 GetInt32(WChar type = 0)
|
int32 GetInt32(WChar type = 0)
|
||||||
|
|
Loading…
Reference in New Issue