# HG changeset patch # User Jonathan G Rennison # Date 2021-06-19 21:31:23 # Node ID ab9b7d7dd0ba474e1be6f054b1b8d0f7da6a2eef # Parent e21936138af315cd70e16dd150233de27ab01b30 Fix #8169: nullptr dereference when autoreplacing vehicle with no orders (#9387) diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -207,6 +207,7 @@ static int GetIncompatibleRefitOrderIdFo const Vehicle *u = (v->type == VEH_TRAIN) ? v->First() : v; const OrderList *orders = u->orders.list; + if (orders == nullptr) return -1; for (VehicleOrderID i = 0; i < orders->GetNumOrders(); i++) { o = orders->GetOrderAt(i); if (!o->IsRefit()) continue;