diff --git a/src/util/k_d_tree.h b/src/util/k_d_tree.h index e8ff33fe1..3486b277d 100644 --- a/src/util/k_d_tree.h +++ b/src/util/k_d_tree.h @@ -353,10 +353,11 @@ class KdTree { } template - void rangeQuery(Idx root, uint8_t split, + // Note: root is of type std::size_t to avoid issues with wraparound + void rangeQuery(std::size_t root, uint8_t split, const Point &min, const Point &max, const F &cb) const { - if (root >= cap()) // TODO what if we overflow earlier? + if (root >= cap()) return; const auto ptid = tree[root]; const auto coord = items.points.begin(split)[ptid];