mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 22:41:10 +01:00
The glyf outline budget was only charged after a glyph loaded successfully: Glyph::get_points() spent 16 units per node up front, and glyf_accelerator_t::get_points() charged one unit per point only after the whole tree came back. A glyph that loaded ~175K points and then tripped a structural cap (HB_GLYF_MAX_POINTS, edge count) paid for the nodes but not the points. Driven from a COLR paint walk through hb_font_get_glyph_extents(), one such glyph was loaded and thrown away over 8000 times per session within the budget, ~1.4G point loads. Charge at the point where the work is attempted instead: - SimpleGlyph::get_contour_points() takes the budget and charges num_points before allocating, clearing, and reading, so truncated or later-rejected glyphs pay for the points they allocate. - Composite levels charge the component subtree size before transform_points(), since each nesting level transforms every point below it and that multiplication was previously invisible to the budget. The terminal per-point charge for path emission is unchanged. Local hb-vector-fuzzer run on the testcase: 4.3s -> 0.12s. Full test suite passes. The testcase is added as a fuzz seed. Fixes: https://oss-fuzz.com/testcase-detail/5714817420427264 Claude-Session: https://claude.ai/code/session_013ksLGe7wUVwbuANqR56YaN Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>