Changeset - r23726:97431e47d49a
[Not reviewed]
master
0 1 0
PeterN - 6 years ago 2019-05-10 20:36:03
peter1138@openttd.org
Fix #7577: Check if linkgraph station index is valid before dereferencing. (#7583)
1 file changed with 4 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/saveload/linkgraph_sl.cpp
Show inline comments
 
@@ -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);
 
			}
 
		}
 
	}
0 comments (0 inline, 0 general)