hb_color_line_get_color_stops() defines *count as in/out: capacity on
entry, number of stops written on exit. The skip-to-start early return
added in #6121 (to avoid an infinite loop when FT_Get_Colorline_Stops()
refuses a stop) writes no stops but left *count untouched, so an embedder
paging a malformed ColorLine with start > 0 reads uninitialized
hb_color_stop_t entries and draws the gradient from its own buffer.
Set *count = 0 on that exit, matching the start >= num_color_stops exit
a few lines above and the hb-ot ColorLine::get_color_stops(). Well-formed
fonts are unaffected; no API/ABI change.
Adds test_color_stops_short_ft with a generated 392-byte font whose
ColorLine declares one more stop than it holds.
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-O5RJ72EZ.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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>
The COLRv1 paint walk bounds paint-table visits (HB_MAX_NESTING_LEVEL,
HB_MAX_GRAPH_EDGE_COUNT) but handed out ColorLine stops uncharged, so a
single 65535-stop ColorLine shared across up to 16384 gradient edges
could deliver ~10^9 stops from one hb_font_paint_glyph() call, keeping
the rendering thread busy for minutes per glyph in every backend.
Give hb_paint_context_t the session's live budget via
funcs->get_budget_remaining_ptr(), with the same local HB_BUDGET_GLYPH
fallback hb_draw_session_t uses, charge HB_BUDGET_16 per stop delivered
in ColorLine::get_color_stops() (the one place every consumer fetches
stops, so vector, raster, cairo and client paint functions are all
covered), and make recurse() skip further paints once the budget is
negative, as it already does for an oversized graph. The backend's one
budget is only spent, never re-armed, so this does not reintroduce the
cross-subsystem budget multiplication removed in #6147. hb-ft-colr.hh
has the same shape and gets the identical change.
With the default 2^24 budget about a million stops per session are
delivered before the rest of the walk is skipped best-effort. A
separate quadratic cost inside cairo's own gradient pattern building is
not addressed here. Adds a regression test that fails without the fix.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-F2NWHRVP.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Release the face lock around solid, gradient, and custom palette
callbacks. Keep lazy FreeType color-stop reads locked and give each
getter call its own iterator, so callbacks can query the same font
without deadlocking or disturbing another stop query.
Snapshot the selected palette once per COLRv1 traversal, shared by
the bounds and paint passes. Nested paints can select a different
palette on the face; they must not change the outer paint's colors.
Return failure if the palette copy cannot be allocated. Stops remain
lazy and no cache policy or limits change.
Add a bounded callback regression with the existing COLRv1 fixture.
It queries font extents, performs nested paints with another palette,
and checks repeated and paged stop reads against the OT backend.
The original code times out; unlocking without copying the palette
fails the color comparison. The full Meson suite passes: 274 tests, no failures.
Reported by Anthropic's OSS Scanner as ANT-2026-YPLDSFHA.
Assisted-by: OpenAI Codex
Expose budget policy and remaining-work callbacks on draw and paint function
objects. The public setters clamp invalid negative caps, distinguish finite
defaults from explicit unlimited operation, and report whether a backend
participates in accounting.
Let draw sessions borrow the live counter owned by draw_data. OpenType glyf
and CFF traversal then debit the same counter in place, while unsupported
backends retain a finite per-glyph fallback. Forward budget access through
the parent-font draw adaptor.
Document the new API and cover nil, default, unlimited, clamped, concrete,
and live-depletion behavior.
Tests: meson test -C build (272/272 passed)
Assisted-by: OpenAI Codex <codex@openai.com>
The dispatch wrapper handed the callback user_data->push_clip_glyph
instead of user_data->color_glyph, so a client registering both
callbacks with different contexts got the wrong pointer on every
COLR glyph.
Reduce linear gradient anchors and normalize color lines before
printing them in test-paint. This makes the transcript reflect the
renderer-facing gradient geometry instead of backend-specific raw
COLRv1 anchors and stop ranges.
Also normalize signed zero in transform output so the fixtures stay
stable across backends.
Testing:
CCACHE_DISABLE=1 meson test -C build test-paint --print-errorlogs
Assisted-by: OpenAI Codex
Folded into the existing test-paint binary. Two tests,
both font-independent (registered ahead of the glyph-based
flavor setup so they run even on builds without the test
COLRv1 font):
* test_push_clip_path_nil_returns_null: an unset paint-funcs
table returns NULL from push_clip_path_start and clears
the out-param draw_data, and push_clip_path_end is safe
to call on the nil stub.
* test_push_clip_path_round_trip: registered start/end fire
in order, the returned draw-funcs + draw-data round-trip
through the public entry points, and every hb_draw_*()
call reaches the sink accumulator. Asserts the count
includes hb_draw_close_path's synthetic back-to-start
line_to so the contract is documented by the test.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When generating the expected output with GENERATE_DATA=1,
Glib's test framework puts out some comments at the top
of the file. Ignore them when comparing the expected
output. This makes it possible to directly use the output
of
GENERATE_DATA=1 ./test-paint -p TESTCASE
as expected result for TESTCASE.