diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bcf36c0af3..f12eac0a467 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - FIXED: Fixed Boost link flags in pkg-config file. [#6083](https://github.com/Project-OSRM/osrm-backend/pull/6083) - Routing: - FIXED: Fix generation of inefficient MLD partitions [#6084](https://github.com/Project-OSRM/osrm-backend/pull/6084) + - FIXED: Fix metric offset overflow for large MLD partitions [#6124](https://github.com/Project-OSRM/osrm-backend/pull/6124) # 5.25.0 - Changes from 5.24.0 diff --git a/include/partitioner/cell_storage.hpp b/include/partitioner/cell_storage.hpp index 42c347861d2..3df8748262b 100644 --- a/include/partitioner/cell_storage.hpp +++ b/include/partitioner/cell_storage.hpp @@ -52,14 +52,13 @@ namespace detail template class CellStorageImpl { public: - using ValueOffset = std::uint32_t; - using BoundaryOffset = std::uint32_t; + using ValueOffset = std::size_t; + using BoundaryOffset = std::size_t; using BoundarySize = std::uint32_t; - using SourceIndex = std::uint32_t; - using DestinationIndex = std::uint32_t; static constexpr auto INVALID_VALUE_OFFSET = std::numeric_limits::max(); static constexpr auto INVALID_BOUNDARY_OFFSET = std::numeric_limits::max(); + static constexpr auto MAX_BOUNDARY_SIZE = std::numeric_limits::max(); struct CellData { @@ -324,7 +323,10 @@ template class CellStorageImpl [this, insert_cell_boundary](auto begin, auto end) { insert_cell_boundary( source_boundary, - [](auto &cell, auto value) { cell.num_source_nodes = value; }, + [](auto &cell, auto value) { + BOOST_ASSERT(value < MAX_BOUNDARY_SIZE); + cell.num_source_nodes = value; + }, [](auto &cell, auto value) { cell.source_boundary_offset = value; }, begin, end); @@ -335,7 +337,10 @@ template class CellStorageImpl [this, insert_cell_boundary](auto begin, auto end) { insert_cell_boundary( destination_boundary, - [](auto &cell, auto value) { cell.num_destination_nodes = value; }, + [](auto &cell, auto value) { + BOOST_ASSERT(value < MAX_BOUNDARY_SIZE); + cell.num_destination_nodes = value; + }, [](auto &cell, auto value) { cell.destination_boundary_offset = value; }, begin, end);