From cb222b6df855da4196a331c5b9859750c4321fa0 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 13 Feb 2011 20:47:44 +0000 Subject: [PATCH] Check track iterators for validity before using --- source/libr2c2/train.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/libr2c2/train.cpp b/source/libr2c2/train.cpp index b2b4899..5b03e9b 100644 --- a/source/libr2c2/train.cpp +++ b/source/libr2c2/train.cpp @@ -1294,7 +1294,7 @@ bool Train::is_valid_diversion(const Route &diversion, const TrackIter &from) track1 = track1.next(path); - if(track1.looped()) + if(!track1 || track1.looped()) return false; } @@ -1312,6 +1312,8 @@ bool Train::is_valid_diversion(const Route &diversion, const TrackIter &from) bool ok = (track2!=from && diversion.has_track(*track2)); track2 = track2.next(path); + if(!track2) + return false; if(ok) break; -- 2.45.2