changeset 15087:cf6b5f0aae1d draft

(svn r19713) -Fix [NewGRF]: passing some invalid data to industry variable 67/68 could cause a crash
author rubidium <rubidium@openttd.org>
date Sat, 24 Apr 2010 19:06:54 +0000
parents 125340550a4f
children a63b4234140f
files src/newgrf_industries.cpp
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -131,6 +131,9 @@
 			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 */