Skip to content

Fix u16 overflow in 2-bit and 4-bit bitmap decoders#76

Merged
igorlira merged 1 commit intomainfrom
fix/bitmap-u16-overflow
Mar 14, 2026
Merged

Fix u16 overflow in 2-bit and 4-bit bitmap decoders#76
igorlira merged 1 commit intomainfrom
fix/bitmap-u16-overflow

Conversation

@matthewdean
Copy link
Collaborator

Summary

  • Fix arithmetic overflow panic in decode_bitmap_2bit and decode_bitmap_4bit when index calculations (y * scan_width + x) exceed u16 max (65535)
  • Cast operands to usize before multiplying, matching the existing fix in decode_bitmap_1bit
  • Fixes crash when loading World Builder and other movies with large bitmaps

Test plan

  • Verified World Builder (worldbuilder.dcr) loads and renders correctly after fix
  • Verify other movies with 2-bit and 4-bit bitmaps still render correctly

🤖 Generated with Claude Code

The index calculations (y * scan_width + x) were done in u16 arithmetic,
causing overflow panics for bitmaps where the product exceeds 65535.
Cast to usize before multiplying, matching the existing fix in the 1-bit decoder.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@matthewdean matthewdean requested a review from igorlira March 13, 2026 03:01
@igorlira
Copy link
Owner

Looks good with the movies I tested :)

@igorlira igorlira merged commit bc49dca into main Mar 14, 2026
1 check 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