summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeterN <peter1138@openttd.org>2019-05-10 21:36:03 +0100
committerGitHub <noreply@github.com>2019-05-10 21:36:03 +0100
commit83c1678f9eb75e1a470e477dbeb02e95ad75eabc (patch)
tree0f46f3151c78fc1b11a9ee6b27a2125010198353
parentf4921d2c3ee25139c77278da5fc33194f0cbf075 (diff)
downloadopenttd-83c1678f9eb75e1a470e477dbeb02e95ad75eabc.tar.xz
Fix #7577: Check if linkgraph station index is valid before dereferencing. (#7583)
-rw-r--r--src/saveload/linkgraph_sl.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/saveload/linkgraph_sl.cpp b/src/saveload/linkgraph_sl.cpp
index e8f10d3cd..0280cb1f6 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<LinkGraph &>(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);
}
}
}