From afc5962881bbc485d66ac06544e891787b581aed Mon Sep 17 00:00:00 2001 From: PeterN Date: Fri, 10 May 2019 21:36:03 +0100 Subject: [PATCH] Fix #7577: Check if linkgraph station index is valid before dereferencing. (#7583) --- src/saveload/linkgraph_sl.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/saveload/linkgraph_sl.cpp b/src/saveload/linkgraph_sl.cpp index 76390a0101..50a0b62e69 100644 --- a/src/saveload/linkgraph_sl.cpp +++ b/src/saveload/linkgraph_sl.cpp @@ -233,7 +233,8 @@ void AfterLoadLinkGraphs() LinkGraph *lg; FOR_ALL_LINK_GRAPHS(lg) { for (NodeID node_id = 0; node_id < lg->Size(); ++node_id) { - (*lg)[node_id].UpdateLocation(Station::Get((*lg)[node_id].Station())->xy); + const Station *st = Station::GetIfValid((*lg)[node_id].Station()); + if (st != nullptr) (*lg)[node_id].UpdateLocation(st->xy); } } @@ -241,7 +242,8 @@ void AfterLoadLinkGraphs() FOR_ALL_LINK_GRAPH_JOBS(lgj) { lg = &(const_cast(lgj->Graph())); for (NodeID node_id = 0; node_id < lg->Size(); ++node_id) { - (*lg)[node_id].UpdateLocation(Station::Get((*lg)[node_id].Station())->xy); + const Station *st = Station::GetIfValid((*lg)[node_id].Station()); + if (st != nullptr) (*lg)[node_id].UpdateLocation(st->xy); } } }