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

View File

@ -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))

View File

@ -23,11 +23,9 @@ std::string getWrongOptionHelp(const engine::api::NearestParameters &parameters)
const auto coord_size = parameters.coordinates.size();
const bool param_size_mismatch =
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, coord_size, help);
constrainParamSize(
PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, coord_size, help) ||
constrainParamSize(
PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help) ||
PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help);
constrainParamSize(
PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help);

View File

@ -355,7 +355,7 @@ int main(int argc, const char *argv[]) try
else
{
util::Log(logWARNING) << "Didn't exit within 2 seconds. Hard abort!";
server_task.reset(); // just kill it
std::exit(EXIT_FAILURE);
}
}