Fix #7836: Check coherency of NewGRF parameter min/max (#7840)

This commit is contained in:
glx22 2019-11-23 14:21:01 +01:00 committed by Charles Pigott
parent ef8455f549
commit d865916a07
1 changed files with 8 additions and 2 deletions

View File

@ -7941,8 +7941,14 @@ static bool ChangeGRFParamLimits(size_t len, ByteReader *buf)
grfmsg(2, "StaticGRFInfo: expected 8 bytes for 'INFO'->'PARA'->'LIMI' but got " PRINTF_SIZE ", ignoring this field", len);
buf->Skip(len);
} else {
_cur_parameter->min_value = buf->ReadDWord();
_cur_parameter->max_value = buf->ReadDWord();
uint32 min_value = buf->ReadDWord();
uint32 max_value = buf->ReadDWord();
if (min_value <= max_value) {
_cur_parameter->min_value = min_value;
_cur_parameter->max_value = max_value;
} else {
grfmsg(2, "StaticGRFInfo: 'INFO'->'PARA'->'LIMI' values are incoherent, ignoring this field");
}
}
return true;
}