summaryrefslogtreecommitdiff
path: root/src/newgrf_industries.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-04-24 19:06:54 +0000
committerrubidium <rubidium@openttd.org>2010-04-24 19:06:54 +0000
commit82136fbc62301c0f350c51d438c10be04c863720 (patch)
tree89265d562dcd2df0a30d0833ef5a852bc7e3e59f /src/newgrf_industries.cpp
parent03c6f51c844c8d901f658a2712ebe2dcfdcd65d3 (diff)
downloadopenttd-82136fbc62301c0f350c51d438c10be04c863720.tar.xz
(svn r19713) -Fix [NewGRF]: passing some invalid data to industry variable 67/68 could cause a crash
Diffstat (limited to 'src/newgrf_industries.cpp')
-rw-r--r--src/newgrf_industries.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp
index 467879c73..5c3c0027a 100644
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -131,6 +131,9 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
break;
}
+ /* If the industry type is invalid, there is none and the closest is far away. */
+ if (ind_index >= NUM_INDUSTRYTYPES) return 0 | 0xFFFF;
+
if (layout_filter == 0) {
/* If the filter is 0, it could be because none was specified as well as being really a 0.
* In either case, just do the regular var67 */