diff --git a/src/engine/routing_algorithms/shortest_path.cpp b/src/engine/routing_algorithms/shortest_path.cpp index 38cf90deef3..5a5eace40f2 100644 --- a/src/engine/routing_algorithms/shortest_path.cpp +++ b/src/engine/routing_algorithms/shortest_path.cpp @@ -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)) diff --git a/src/server/service/nearest_service.cpp b/src/server/service/nearest_service.cpp index ad5c657fcda..4393abc0861 100644 --- a/src/server/service/nearest_service.cpp +++ b/src/server/service/nearest_service.cpp @@ -23,13 +23,11 @@ std::string getWrongOptionHelp(const engine::api::NearestParameters ¶meters) 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, "bearings", parameters.bearings, coord_size, help) || - constrainParamSize( - PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, 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); + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help); return help; } diff --git a/src/tools/routed.cpp b/src/tools/routed.cpp index a66f61f7fbc..9fa66b05453 100644 --- a/src/tools/routed.cpp +++ b/src/tools/routed.cpp @@ -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); } }