From 50d5ab3241f01eb13b9342f54344c6640ab9875f Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Sun, 19 May 2024 21:44:20 +0200 Subject: [PATCH] Fix potential wraparound issue --- src/util/k_d_tree.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/k_d_tree.h b/src/util/k_d_tree.h index 3486b277d..cdb07c20c 100644 --- a/src/util/k_d_tree.h +++ b/src/util/k_d_tree.h @@ -68,7 +68,7 @@ class Points { //! Empty Points() : n(0), coords(nullptr) {} //! Allocating constructor; leaves coords uninitialized! - Points(Idx n) : n(n), coords(new Component[Dim * n]) {} + Points(Idx n) : n(n), coords(new Component[Dim * static_cast(n)]) {} //! Copying constructor Points(Idx n, const std::array &coords) : Points(n) { for (uint8_t d = 0; d < Dim; ++d) @@ -92,13 +92,13 @@ class Points { begin(d)[i] = point[d]; } Component *begin(uint8_t d) { - return coords.get() + d * n; + return coords.get() + d * static_cast(n); } Component *end(uint8_t d) { return begin(d) + n; } const Component *begin(uint8_t d) const { - return coords.get() + d * n; + return coords.get() + d * static_cast(n); } const Component *end(uint8_t d) const { return begin(d) + n;