Skip to content

Commit c5744ee

Browse files
authored
Merge pull request #661 from Maxxen/v1.3.2-dev
fix incorrect end node index access in large polygon-distance check
2 parents c94e84f + 92c7ce0 commit c5744ee

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/sgl/sgl.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2409,7 +2409,13 @@ point_in_polygon_result prepared_geometry::contains(const vertex_xy &vert) const
24092409
return crossings % 2 == 0 ? point_in_polygon_result::EXTERIOR : point_in_polygon_result::INTERIOR;
24102410
}
24112411

2412-
if(stack[depth] != index.level_array[depth].entry_count - 1) {
2412+
// The end of this node is either the end of the current node, or the end of the level
2413+
const auto node_end = ((stack[depth - 1] + 1) * NODE_SIZE) - 1;
2414+
const auto levl_end = index.level_array[depth].entry_count - 1;
2415+
2416+
const auto end = math::min(node_end, levl_end);
2417+
2418+
if(stack[depth] != end) {
24132419
// Go sideways!
24142420
stack[depth]++;
24152421
break;

0 commit comments

Comments
 (0)