]> git.tdb.fi Git - r2c2.git/commitdiff
Check track iterators for validity before using
authorMikko Rasa <tdb@tdb.fi>
Sun, 13 Feb 2011 20:47:44 +0000 (20:47 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sun, 13 Feb 2011 20:47:44 +0000 (20:47 +0000)
source/libr2c2/train.cpp

index b2b4899f9aa6eb7cc1ad83cee23039d073c4b5f4..5b03e9b5e6946827a966080de5fb86084a8db0fa 100644 (file)
@@ -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;