diff -r f37aaf33593b src/order_cmd.cpp --- a/src/order_cmd.cpp Sun Jan 04 14:55:04 2009 +0100 +++ b/src/order_cmd.cpp Sun Jan 04 16:09:29 2009 +0100 @@ -643,6 +643,10 @@ } if (sel_ord > v->GetNumOrders()) return CMD_ERROR; + + /** v->orders.list->num_orders == INVALID_VEH_ORDER_ID would mean that the OrderList is invalid + * therefore we cannot allow the number of orders to become bigger than INVALID_VEH_ORDER_ID - 1 */ + if (v->GetNumOrders() >= INVALID_VEH_ORDER_ID - 1) return_cmd_error(STR_8832_TOO_MANY_ORDERS); if (!Order::CanAllocateItem()) return_cmd_error(STR_8831_NO_MORE_SPACE_FOR_ORDERS); if (v->orders.list == NULL && !OrderList::CanAllocateItem()) return_cmd_error(STR_8831_NO_MORE_SPACE_FOR_ORDERS);