Skip to content

win32: avoid overflow when negating wheel deltas - #4726

Open
mikamikasuki wants to merge 1 commit into
rust-windowing:masterfrom
mikamikasuki:fix/windows-wheel-delta-overflow-4722
Open

mikamikasuki wants to merge 1 commit into
rust-windowing:masterfrom
mikamikasuki:fix/windows-wheel-delta-overflow-4722

Conversation

@mikamikasuki

Copy link
Copy Markdown

Fixes #4722.

Both horizontal Win32 wheel paths negate a signed i16 before converting it to f32. For i16::MIN, that overflows in debug builds and wraps in release builds. Convert to f32 before negation and share the conversion helper.

Add a regression test for i16::MIN and the ordinary ±120 wheel deltas, and note the fix in the changelog.

Validation:

  • cargo +1.98.1 check -p winit-win32 --tests --target x86_64-pc-windows-gnu
  • cargo +nightly fmt --all -- --check
  • git diff --check

The Windows-only test cannot run on this macOS host; Windows CI can execute it.

  • Tested on all platforms changed
  • Added an entry to the changelog module
  • Updated documentation beyond the changelog
  • Created or updated an example program

This branch has not been deployed

No deployments
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.

Delta overflow error

1 participant