Fix segfault when route includes very short segments.

This commit is contained in:
Daniel Patterson
2016-06-22 13:25:22 -07:00
parent 256d39b572
commit 6dedd9cb72
5 changed files with 23 additions and 4 deletions
+2 -2
View File
@@ -894,13 +894,13 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
auto &next_to_last_step = *(steps.end() - 2);
// in the end, the situation with the roundabout cannot occur. As a result, we can remove
// all zero-length instructions
if (next_to_last_step.distance <= 1)
if (next_to_last_step.distance <= 1 && steps.size() > 2)
{
geometry.locations.pop_back();
geometry.annotations.pop_back();
geometry.osm_node_ids.pop_back();
geometry.segment_offsets.pop_back();
BOOST_ASSERT(geometry.segment_distances.back() < 1);
BOOST_ASSERT(geometry.segment_distances.back() <= 1);
geometry.segment_distances.pop_back();
next_to_last_step.maneuver.waypoint_type = WaypointType::Arrive;