(svn r3146) Avoid use of variable size declared arrays when allocating articulated rail vehicles.
authorpeter1138
Sun, 06 Nov 2005 12:39:30 +0000
changeset 2609 b2c7aa8ce0c4
parent 2608 f7f41be75b48
child 2610 044cb4ffc6f7
(svn r3146) Avoid use of variable size declared arrays when allocating articulated rail vehicles.
train_cmd.c
--- a/train_cmd.c	Sun Nov 06 10:17:20 2005 +0000
+++ b/train_cmd.c	Sun Nov 06 12:39:30 2005 +0000
@@ -515,7 +515,7 @@
 	num_vehicles = 1 + CountArticulatedParts(rvi, engine);
 
 	if (!(flags & DC_QUERY_COST)) {
-		Vehicle *vl[num_vehicles];
+		Vehicle *vl[11]; // Allow for wagon and upto 10 artic parts.
 
 		if (!AllocateVehicles(vl, num_vehicles))
 			return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
@@ -701,7 +701,7 @@
 	num_vehicles += CountArticulatedParts(rvi, p1);
 
 	if (!(flags & DC_QUERY_COST)) {
-		Vehicle *vl[num_vehicles];
+		Vehicle *vl[12]; // Allow for upto 10 artic parts and dual-heads
 		if (!AllocateVehicles(vl, num_vehicles) || IsOrderPoolFull())
 			return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);