From d4f9cd53d22cbe57a58555c542c505e02b9a75f1 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Fri, 10 May 2019 21:00:57 +0100 Subject: [PATCH] Fix #7577: Check if linkgraph station index is valid before dereferencing. --- 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 e8f10d3cd33f..0280cb1f6900 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); } } }