mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-24 08:21:32 +01:00
hb_paint_sweep_gradient_tiles() documents that it iterates the 0..2π sweep, and all three consumers (hb-cairo mesh patches, the SVG and PDF writers) size their per-tile loops by tile width on that assumption. Several emit sites (the start==end PAD case, the first PAD stop past 0, and repeat/reflect segments straddling 0 or 2π) passed the angles straight through, and COLRv1 variation deltas can place them hundreds of thousands of radians outside the circle, so one tile could expand to millions of patches: a 504-byte variable font drawn off its default allocated ~1.6 GiB through hb-cairo. #6157 bounded the number of sweep tiles; this bounds the width of each one. Route every emit through a small clipping lambda inside the tiler that clamps the tile to [0, 2π], lerps the end colours at the clip points, and drops tiles entirely outside, so the contract holds at the single place it is established rather than in each backend. HB_PAINT_MAX_SWEEP_TILES and the repeat-loop bounds are untouched; external callers need no change. Adds a regression test calling the public function with far-out angles for PAD/REPEAT/REFLECT; it fails without the fix. Follow-up to #6157. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-GCNW3SND. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>