mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-23 15:48:21 +00:00
c8c1522953
FreeType’s FT_Glyph_To_Bitmap mutates the FT_Glyph by allocating a new glyph object and overwriting the input pointer. This creates a risk of memory leaks if the old glyph isn’t released or if ownership is unclear. To avoid this, we now store the glyph in a UniqueFTGlyph and explicitly pass it by reference to FT_Glyph_To_Bitmap. After the mutation, ownership continues to reside in the smart pointer, and cleanup is guaranteed even in error branches. For temporary glyphs (e.g., strokes), we still manually call FT_Done_Glyph, since they are not managed by UniqueFTGlyph. These changes ensure all glyph memory is correctly released and reduce the need for repetitive error-path cleanup code.