Skip to content

Added check for empty bboxes in count_bboxes_overlapping_bbox #5245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/_path.h
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,10 @@ int count_bboxes_overlapping_bbox(agg::rect_d &a, BBoxArray &bboxes)
agg::rect_d b;
int count = 0;

// If bboxes is empty return zero
if (bboxes.dim(0) == 0 || bboxes.dim(1) == 0 || bboxes.dim(2) == 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe say: bboxes.dim(1) != 2 || bboxes.dim(2) != 2? We are bound to have other issues if its mishapen in some other way. Though having a zero anywhere in the shape doesn't indicate a bug elsewhere, having anything other than 2 in the final two dimensions does, so maybe we need to turn that case into an exception.

return 0;

if (a.x2 < a.x1) {
std::swap(a.x1, a.x2);
}
Expand Down