Skip to content

Commit e346e9a

Browse files
committed
Avoid using signed integers for edge IDs
1 parent ad37fcc commit e346e9a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- FIXED: Remove the last short annotation segment in `trimShortSegments` [#4946](https://github.com/Project-OSRM/osrm-backend/pull/4946)
77
- 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)
88
- 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)
9+
- FIXED: integer overflow in `DynamicGraph::Renumber` [#5021](https://github.com/Project-OSRM/osrm-backend/pull/5021)
910
- Profile:
1011
- CHANGED: Handle oneways in get_forward_backward_by_key [#4929](https://github.com/Project-OSRM/osrm-backend/pull/4929)
1112
- 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)

include/util/dynamic_graph.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#define DYNAMICGRAPH_HPP
33

44
#include "util/deallocating_vector.hpp"
5+
#include "util/exception.hpp"
6+
#include "util/exception_utils.hpp"
57
#include "util/integer_range.hpp"
68
#include "util/permutation.hpp"
79
#include "util/typedefs.hpp"
@@ -411,14 +413,19 @@ template <typename EdgeDataT> class DynamicGraph
411413
util::inplacePermutation(node_array.begin(), node_array.end(), old_to_new_node);
412414

413415
// Build up edge permutation
414-
auto new_edge_index = 0;
416+
EdgeID new_edge_index = 0;
415417
std::vector<EdgeID> old_to_new_edge(edge_list.size(), SPECIAL_EDGEID);
416418
for (auto node : util::irange<NodeID>(0, number_of_nodes))
417419
{
418420
auto new_first_edge = new_edge_index;
419421
// move all filled edges
420422
for (auto edge : GetAdjacentEdgeRange(node))
421423
{
424+
if (new_edge_index == std::numeric_limits<EdgeID>::max())
425+
{
426+
throw util::exception("There are too many edges, OSRM only supports 2^32" +
427+
SOURCE_REF);
428+
}
422429
edge_list[edge].target = old_to_new_node[edge_list[edge].target];
423430
BOOST_ASSERT(edge_list[edge].target != SPECIAL_NODEID);
424431
old_to_new_edge[edge] = new_edge_index++;

0 commit comments

Comments
 (0)