Skip to content

[rtext] Validate GenImageFontAtlas atlas size to prevent integer-overflow out-of-bounds write - #6407

Closed
JohnEarle wants to merge 1 commit into
raysan5:masterfrom
BlackChamberLabs:fix/genimagefontatlas-atlas-overflow
Closed

JohnEarle wants to merge 1 commit into
raysan5:masterfrom
BlackChamberLabs:fix/genimagefontatlas-atlas-overflow

Conversation

@JohnEarle

Copy link
Copy Markdown

Fixes #6406.

atlasDataSize = atlas.width*atlas.height can overflow int for a crafted font (e.g. width = height = 65536 → 65536*65536 wraps to 0), so RL_CALLOC returns a 0-byte atlas and the copy loop writes out of bounds. This validates the atlas size in 64-bit and bails out with a warning on malformed/oversized dimensions, before the allocation.

Minimal change, no behaviour change for valid fonts. Reproduced on master and 6.2 — PoC in #6406.

— BlackChamber Labs

@raysan5 raysan5 closed this Nov 11, 2026
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.

[rtext] Integer overflow in GenImageFontAtlas atlas-size calculation causes out-of-bounds write

2 participants