# HG changeset patch # User rubidium # Date 2010-04-24 19:06:54 # Node ID f52f97d194e2afc9643bc684601fe82a2f544823 # Parent bf67615e69aa596850c4586edd3acf8110ca24d9 (svn r19713) -Fix [NewGRF]: passing some invalid data to industry variable 67/68 could cause a crash diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -131,6 +131,9 @@ static uint32 GetCountAndDistanceOfClose 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 */