]> git.tdb.fi Git - r2c2.git/commitdiff
Don't access waypoint and metric data if the router has no destination
authorMikko Rasa <tdb@tdb.fi>
Thu, 5 Feb 2015 13:53:32 +0000 (15:53 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 5 Feb 2015 13:53:32 +0000 (15:53 +0200)
source/libr2c2/trainrouteplanner.cpp

index dbe6035499c9e61663b2f6337448c35e5518b9d2..0d0103cb3f4ef274cd1ea4544d2557f87a9fa8c5 100644 (file)
@@ -213,15 +213,18 @@ TrainRoutePlanner::TrainRoutingInfo::TrainRoutingInfo(Train &t):
        if(router)
        {
                destination = router->get_destination();
-               waypoints.resize(router->get_n_waypoints());
-               metrics.resize(waypoints.size()+1);
-               metrics[0] = &router->get_metric(-1);
-               for(unsigned i=0; i<waypoints.size(); ++i)
+               if(destination)
                {
-                       waypoints[i] = &router->get_waypoint(i);
-                       metrics[i+1] = &router->get_metric(i);
+                       waypoints.resize(router->get_n_waypoints());
+                       metrics.resize(waypoints.size()+1);
+                       metrics[0] = &router->get_metric(-1);
+                       for(unsigned i=0; i<waypoints.size(); ++i)
+                       {
+                               waypoints[i] = &router->get_waypoint(i);
+                               metrics[i+1] = &router->get_metric(i);
+                       }
+                       has_duration = router->get_trip_duration();
                }
-               has_duration = router->get_trip_duration();
        }
 
        // If no maximum speed is specified, use a sensible default