8000 fix(macos): treat keycode 128 as unknown (off-by-one bounds) by arimu1 · Pull Request #427 · emoon/rust_minifb · GitHub
[go: up one dir, main page]

Skip to content

fix(macos): treat keycode 128 as unknown (off-by-one bounds) - #427

Merged
emoon merged 1 commit into
emoon:masterfrom
arimu1:fix/413-keycode-bounds
Aug 1, 2026
Merged

emoon merged 1 commit into
emoon:masterfrom
arimu1:fix/413-keycode-bounds

Conversation

@arimu1
@arimu1 arimu1 commented Jul 31, 2026
Copy link
Copy Markdown
Contributor

Summary

On macOS, key_callback used if key > 128 before indexing KEY_MAPPINGS: [Key; 128]. Keycode 128 was treated as in-bounds and panicked with an out-of-range index inside an extern "C" ObjC callback.

The check is now key < 0 || key >= 128, mapping those codes to Key::Unknown.

Fixes #413

Test plan

  • cargo check on the branch
  • Reviewed KEY_MAPPINGS length (128) against the new bound

KEY_MAPPINGS has 128 entries (0..127). The previous bound check used
`key > 128`, so keycode 128 indexed past the end of the table inside an
ObjC callback and could panic.

Fixes emoon#413
@emoon
emoon merged commit 6701141 into emoon:master Aug 1, 2026
4 checks passed
@emoon
emoon commented Aug 1, 2026
Copy link
Copy Markdown
Owner

Thanks!

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.

macOS: keycode bounds check off-by-one

2 participants

0