diff --git a/CHANGELOG.md b/CHANGELOG.md index 99d1260bfc7..5fb63a1b9c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - FIXED: Remove the last short annotation segment in `trimShortSegments` [#4946](https://github.com/Project-OSRM/osrm-backend/pull/4946) - FIXED: Properly calculate annotations for speeds, durations and distances when waypoints are used with mapmatching [#4949](https://github.com/Project-OSRM/osrm-backend/pull/4949) - FIXED: Don't apply unimplemented SH and PH conditions in OpeningHours and add inversed date ranges [#4992](https://github.com/Project-OSRM/osrm-backend/issues/4992) + - FIXED: integer overflow in `DynamicGraph::Renumber` [#5021](https://github.com/Project-OSRM/osrm-backend/pull/5021) - Profile: - CHANGED: Handle oneways in get_forward_backward_by_key [#4929](https://github.com/Project-OSRM/osrm-backend/pull/4929) - FIXED: Do not route against oneway road if there is a cycleway in the wrong direction; also review bike profile [#4943](https://github.com/Project-OSRM/osrm-backend/issues/4943) diff --git a/include/util/dynamic_graph.hpp b/include/util/dynamic_graph.hpp index 95eac6d07b8..6fd599759e3 100644 --- a/include/util/dynamic_graph.hpp +++ b/include/util/dynamic_graph.hpp @@ -2,6 +2,8 @@ #define DYNAMICGRAPH_HPP #include "util/deallocating_vector.hpp" +#include "util/exception.hpp" +#include "util/exception_utils.hpp" #include "util/integer_range.hpp" #include "util/permutation.hpp" #include "util/typedefs.hpp" @@ -411,7 +413,7 @@ template class DynamicGraph util::inplacePermutation(node_array.begin(), node_array.end(), old_to_new_node); // Build up edge permutation - auto new_edge_index = 0; + EdgeID new_edge_index = 0; std::vector old_to_new_edge(edge_list.size(), SPECIAL_EDGEID); for (auto node : util::irange(0, number_of_nodes)) { @@ -419,6 +421,11 @@ template class DynamicGraph // move all filled edges for (auto edge : GetAdjacentEdgeRange(node)) { + if (new_edge_index == std::numeric_limits::max()) + { + throw util::exception("There are too many edges, OSRM only supports 2^32" + + SOURCE_REF); + } edge_list[edge].target = old_to_new_node[edge_list[edge].target]; BOOST_ASSERT(edge_list[edge].target != SPECIAL_NODEID); old_to_new_edge[edge] = new_edge_index++;