mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-24 08:21:32 +01:00
hb_ft_font_set_funcs() assumed the FT_Face it creates is adopted by hb_font_set_funcs(), but on an immutable font that call only runs the destroy callback, which FT_Done_Face()s the face. The trailing _hb_ft_hb_font_changed() then called FT_Set_Char_Size()/FT_Set_Transform() on freed memory, crashing an application that merely called the setter on a frozen hb-ft font (e.g. one already passed to hb_cairo_font_face_create_for_font()). Add the same early hb_object_is_immutable() return that the sibling setter hb_ft_font_set_load_flags() and hb_font_set_funcs_using() already have, so the call fails silently as the object model documents and no FT_Face/FT_Library reference is created at all. No change for mutable fonts; no API/ABI change. Adds test_native_ft_set_funcs_immutable, which reports the heap-use-after-free under ASan without the fix and passes with it. Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-XZWHSHHC. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>