Repository navigation
[rtext] Fix BDF font loading crash (glyph pointer reset to NULL) - #6198
Merged
Merged
Conversation
LoadFontDataBDF() used to track the glyph being filled in a separate charGlyphInfo pointer. Since that pointer was folded into `glyphs`, the loader resets the glyph array itself to NULL at every STARTCHAR and BITMAP line, then computes the current glyph as &glyphs[index] from NULL. Any BDF font with a glyph past the first requested codepoint crashes, and the glyph array leaks. Restore the separate per-glyph pointer, and allocate requiredCodepoints after the NULL check and the default codepoint count are applied.
raysan5
reviewed
Sep 30, 2026
Owner
|
@antonsoo thanks for the review, BDF is barely tested, I think I never used it... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
SUPPORT_FILEFORMAT_BDFenabled, loading a BDF font crashes on 6.0 andmaster.LoadFontDataBDF()used to fill each glyph through a separatecharGlyphInfopointer (as in 5.5). That pointer was merged intoglyphs, so now everySTARTCHARandBITMAPline sets the glyph array itself toNULL, and the current glyph is computed as&glyphs[index]from thatNULL. Any glyph after the first requested codepoint is written to addressindex*sizeof(GlyphInfo)(segfault), and the glyph array leaks.This restores the separate per-glyph pointer. It also allocates
requiredCodepointsafter thefileData == NULLcheck and the default codepoint count, so it no longer leaks on that early return.Tested with three sizes of the Spleen BDF font (5x8, 8x16, 12x24) through
LoadFontEx(), with the default codepoints and with an explicit list including non-ASCII codepoints:LoadFontDataBDFfor all of them (release build and ASan);rtext.cbuilds without new warnings on Linux (gcc) and cross-compiled for Windows (x86_64-windows-gnu), with BDF enabled and disabled.