Skip to content

winit-core: fix inverted RGBA size check for icons and cursors - #4826

Merged
ogoffart merged 1 commit into
rust-windowing:masterfrom
smittie2000:smittie2000/fix-rgba-size-check
Nov 9, 2026
Merged

ogoffart merged 1 commit into
rust-windowing:masterfrom
smittie2000:smittie2000/fix-rgba-size-check

Conversation

@smittie2000

@smittie2000 smittie2000 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

c896b0a ("Use is_multiple_of") replaced rgba.len() % PIXEL_SIZE != 0 with rgba.len().is_multiple_of(PIXEL_SIZE) but dropped the negation. Since then RgbaIcon::new and CustomCursorSource::from_rgba reject every valid RGBA buffer with ByteCountNotDivisibleBy4, and the application example panics on startup while loading its icon and cursors.

This restores the ! in both places and adds unit tests for each constructor that accept a valid buffer and reject one with a partial pixel. The tests fail without the fix.

Discovered while testing #4825 with the application example.

🤖 Generated with Claude Code

@smittie2000 smittie2000 changed the title Fix inverted RGBA size check for icons and cursors winit-core: fix inverted RGBA size check for icons and cursors Nov 8, 2026
@smittie2000
smittie2000 force-pushed the smittie2000/fix-rgba-size-check branch from 5bc95d0 to fc2ec8d Compare November 8, 2026 07:54
c896b0a replaced `len % PIXEL_SIZE != 0` with
`len.is_multiple_of(PIXEL_SIZE)` but dropped the negation, so
`RgbaIcon::new` and `CustomCursorSource::from_rgba` rejected every valid buffer
with `ByteCountNotDivisibleBy4`. Restore the negation and add tests for
both constructors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@smittie2000
smittie2000 force-pushed the smittie2000/fix-rgba-size-check branch from fc2ec8d to 7be4e6e Compare November 8, 2026 08:05

@ogoffart ogoffart left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oops. Apparently there were no tests :-(

@ogoffart
ogoffart merged commit b31115a into rust-windowing:master Nov 9, 2026
53 checks passed
@smittie2000
smittie2000 deleted the smittie2000/fix-rgba-size-check branch November 9, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants