mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-21 23:11:04 +01:00
For partial instancing the subset plan decodes every retained glyph through Glyph::get_all_points_without_var() and keeps all the points in plan->new_gid_contour_points_map until the plan is destroyed. That caller passed no work budget, and nothing capped the total. A simple glyph of repeated flags declares ~65536 points in ~526 bytes, and a loca whose offsets alias one another lets many glyph ids share those bytes, so a 25 KB font drove plan creation to 2.2 GB. PR #6256 added a charge-before-allocate budget to SimpleGlyph::get_contour_points() and passed it from the draw/extents path, but left this subsetter caller unbudgeted. Give the loop one plan-wide budget, the larger of HB_BUDGET_SUBSET_CONTOUR_POINTS and the source glyf length, and charge each glyph's decoded points after it is decoded. One glyph's decode is bounded by the format (about 786 KB), so the transient is proportional to the input; the budget bounds what the plan retains. Exhausting it fails plan creation, the same outcome as any other decode failure in this loop. Ordinary glyph data carries at least one byte per point, so the size-derived bound does not constrain well-formed fonts. Adds an API regression test (test_subset_gvar_shared_glyph_data) with an aliased loca over a 65536-point simple and composite glyph. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-O2ZFVVUI. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>