diff --git a/src/h3lib/lib/polygon.c b/src/h3lib/lib/polygon.c index b09721a39..18f5b858c 100644 --- a/src/h3lib/lib/polygon.c +++ b/src/h3lib/lib/polygon.c @@ -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; } }