From c650f1106f3e8ee1966dcbc821128cdbbb1b378c Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 5 Feb 2015 15:53:32 +0200 Subject: [PATCH] Don't access waypoint and metric data if the router has no destination --- source/libr2c2/trainrouteplanner.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/source/libr2c2/trainrouteplanner.cpp b/source/libr2c2/trainrouteplanner.cpp index dbe6035..0d0103c 100644 --- a/source/libr2c2/trainrouteplanner.cpp +++ b/source/libr2c2/trainrouteplanner.cpp @@ -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; iget_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; iget_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 -- 2.45.2