Skip to content

Avoid divide-by-zero crash in RankFilter#9755

Merged
radarhere merged 3 commits into
python-pillow:mainfrom
lukegb:pls-no-fpe
Jul 7, 2026
Merged

Avoid divide-by-zero crash in RankFilter#9755
radarhere merged 3 commits into
python-pillow:mainfrom
lukegb:pls-no-fpe

Conversation

@lukegb

@lukegb lukegb commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Changes proposed in this pull request:

  • Avoid divide-by-zero crash in image filtering - although a kernel size of 1 is pointless/trivial, but it shouldn't cause the C extension to crash.

Fixes a crash accidentally introduced by the validation logic added in dff01a0.

lukegb and others added 2 commits July 2, 2026 13:07
A kernel size of 1 is pointless/trivial, but it shouldn't cause the C
extension to crash.
@codspeed-hq

codspeed-hq Bot commented Jul 2, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 345 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing lukegb:pls-no-fpe (9f7010d) with main (1cf685c)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@radarhere

radarhere commented Jul 3, 2026

Copy link
Copy Markdown
Member

I've created lukegb#3 with a suggestion - rather than expand the image by zero, I think just copying the image would be more efficient.

You probably want to keep margin > 0 for defensiveness.

@radarhere radarhere changed the title Avoid divide-by-zero crash in image filtering Avoid divide-by-zero crash in RankFilter Jul 7, 2026
@radarhere
radarhere merged commit 94cc03e into python-pillow:main Jul 7, 2026
55 of 56 checks passed
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.

2 participants