Skip to content

Commit

Permalink
guard against numVerts = 0 for hole check
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacbrodsky committed Dec 15, 2023
1 parent 7659732 commit 4f0341c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/h3lib/lib/polygon.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,12 @@ bool cellBoundaryInsidePolygon(const GeoPolygon *geoPolygon, const BBox *bboxes,

// Check for line intersections with, or containment of, any hole
for (int i = 0; i < geoPolygon->numHoles; i++) {
// TODO: There may be numVerts = 0 here, which would cause a crash
if (pointInsideGeoLoop(&boundaryLoop, boundaryBBox,
&geoPolygon->holes[i].verts[0]) ||
cellBoundaryCrossesGeoLoop(&(geoPolygon->holes[i]), &bboxes[i + 1],
boundary, boundaryBBox)) {
// If the hole has no verts, it is not possible to intersect with it.
if (geoPolygon->holes[i].numVerts > 0 &&
(pointInsideGeoLoop(&boundaryLoop, boundaryBBox,
&geoPolygon->holes[i].verts[0]) ||
cellBoundaryCrossesGeoLoop(&(geoPolygon->holes[i]), &bboxes[i + 1],
boundary, boundaryBBox))) {
return false;
}
}
Expand Down

0 comments on commit 4f0341c

Please sign in to comment.