Skip to content

Fix ZeroDivisionError in Shapes._merge_shapes on zero-area groups - #376

Open
jaxorama wants to merge 1 commit into
ArtifexSoftware:masterfrom
jaxorama:fix-merge-shapes-zero-division
Open

Fix ZeroDivisionError in Shapes._merge_shapes on zero-area groups#376
jaxorama wants to merge 1 commit into
ArtifexSoftware:masterfrom
jaxorama:fix-merge-shapes-zero-division

Conversation

@jaxorama

Copy link
Copy Markdown

Shapes._merge_shapes() divides sum_area by merged_area to decide whether a group of same-color, overlapping shapes should be merged into one. Some real-world PDFs (e.g. containing degenerate zero-width border rectangles) produce a group whose merged bounding box has zero area, raising ZeroDivisionError and aborting the whole conversion.

Guard the division so a zero-area group is simply left unmerged instead of crashing, and add a regression test using a minimal same-color, zero-area shape pair (no sample PDF needed to trigger it).

Shapes._merge_shapes() divides sum_area by merged_area to decide
whether a group of same-color, overlapping shapes should be merged
into one. Some real-world PDFs (e.g. containing degenerate zero-width
border rectangles) produce a group whose merged bounding box has zero
area, raising ZeroDivisionError and aborting the whole conversion.

Guard the division so a zero-area group is simply left unmerged
instead of crashing, and add a regression test using a minimal
same-color, zero-area shape pair (no sample PDF needed to trigger it).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant