Fixes use-after-move, closes #3820

This commit is contained in:
Daniel J. Hofmann
2017-03-16 13:59:30 +01:00
committed by Daniel J. H
parent 3c81baa26e
commit 35c4c2a256
3 changed files with 14 additions and 8 deletions
@@ -312,6 +312,11 @@ shortestPathSearchImpl(SearchEngineData &engine_working_data,
new_total_weight_to_reverse = new_total_weight_to_forward;
packed_leg_to_reverse = std::move(packed_leg_to_forward);
new_total_weight_to_forward = INVALID_EDGE_WEIGHT;
// (*)
//
// Below we have to check if new_total_weight_to_forward is invalid.
// This prevents use-after-move on packed_leg_to_forward.
}
else if (target_phantom.reverse_segment_id.enabled)
{
@@ -341,6 +346,9 @@ shortestPathSearchImpl(SearchEngineData &engine_working_data,
}
}
// Note: To make sure we do not access the moved-from packed_leg_to_forward
// we guard its access by a check for invalid edge weight. See (*) above.
// No path found for both target nodes?
if ((INVALID_EDGE_WEIGHT == new_total_weight_to_forward) &&
(INVALID_EDGE_WEIGHT == new_total_weight_to_reverse))