fix segmentation fault for via-routes with invalid intermediate segments

This commit is contained in:
Moritz Kobitzsch 2016-08-22 18:46:37 +02:00
parent 1a22e7da2b
commit 400dd42780
3 changed files with 42 additions and 1 deletions

View File

@ -1,3 +1,8 @@
# 5.3.3
Changes from 5.3.2
- Bugfixes
- Fixed an issue that would result in segfaults for viaroutes with an invalid intermediate segment when u-turns were allowed at the via-location
# 5.3.2
Changes from 5.3.1
- Bugfixes

View File

@ -262,3 +262,35 @@ Feature: Via points
| 3,2,1 | ab,bc,cd,da,ab,ab,ab,bc,cd,da,ab,ab | 3000m +-1 |
| 6,5,4 | bc,cd,da,ab,bc,bc,bc,cd,da,ab,bc,bc | 3000m +-1 |
| 9,8,7 | cd,da,ab,bc,cd,cd,cd,da,ab,bc,cd,cd | 3000m +-1 |
# See issue #2706
Scenario: Incorrect ordering of nodes can produce multiple U-turns
Given the node map
| | a | | | |
| e | b | c | d | f |
And the ways
| nodes | oneway |
| abcd | no |
| ebbdcf | yes |
When I route I should get
| from | to | route |
| e | f | ebbdcf,ebbdcf |
@2798
Scenario: UTurns Enabled
Given the node map
| a | b | c | d | e |
And the query options
| continue_straight | false |
And the ways
| nodes | oneway |
| abc | yes |
| edc | yes |
When I route I should get
| waypoints | route |
| a,b,e | |

View File

@ -114,7 +114,11 @@ class ShortestPathRouting final
needs_loop_forwad,
needs_loop_backwards);
}
new_total_distance += std::min(total_distance_to_forward, total_distance_to_reverse);
// if no route is found between two parts of the via-route, the entire route becomes
// invalid. Adding to invalid edge weight sadly doesn't return an invalid edge weight. Here
// we prevent the possible overflow, faking the addition of infinity + x == infinity
if (new_total_distance != INVALID_EDGE_WEIGHT)
new_total_distance += std::min(total_distance_to_forward, total_distance_to_reverse);
}
// searches shortest path between: