# HG changeset patch # User bjarni # Date 1151571930 0 # Node ID c7259875a8563ec483919a75b1321d3e99a1552d # Parent 55a5642143f1f5e2e41f595b5b252d7848bb740d (svn r5428) -Fix: [vehicles] sovled crash when trying to build a vehicle type, that is set to max 0 (spotted by roboman) somebody might add a better string than "too many vehicles in game" since none are allowed, but at least it will not crash anymore diff -r 55a5642143f1 -r c7259875a856 vehicle.c --- a/vehicle.c Thu Jun 29 08:58:08 2006 +0000 +++ b/vehicle.c Thu Jun 29 09:05:30 2006 +0000 @@ -2054,6 +2054,14 @@ default: NOT_REACHED(); } + if (max == 0) { + /* we can't build any of this kind of vehicle, so we just return 1 instead of looking for a free number + * a max of 0 will cause the following code to write to a NULL pointer + * We know that 1 is bigger than the max allowed vehicle number, so it's the same as returning something, that is too big + */ + return 1; + } + if (max > gmax) { gmax = max; free(cache);