summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglx22 <glx22@users.noreply.github.com>2019-11-23 14:21:01 +0100
committerCharles Pigott <charlespigott@googlemail.com>2019-11-23 13:21:01 +0000
commitd865916a071329ce216c50a2d8b6e6ccbd4fcedd (patch)
treeb30bcebf8d0f6813a06dc701233f77b09a18fe5a /src
parentef8455f5498cc01bc60eb1c02902c38bbc332a7a (diff)
downloadopenttd-d865916a071329ce216c50a2d8b6e6ccbd4fcedd.tar.xz
Fix #7836: Check coherency of NewGRF parameter min/max (#7840)
Diffstat (limited to 'src')
-rw-r--r--src/newgrf.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 9cebb7a59..ce1b2babe 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -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;
}