From b786ea01f033eb4fb233e5ec31de6ba3d8ed5ac1 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 24 Apr 2010 19:06:54 +0000 Subject: [PATCH] (svn r19713) -Fix [NewGRF]: passing some invalid data to industry variable 67/68 could cause a crash --- src/newgrf_industries.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 467879c73b..5c3c0027aa 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 */