Commit Graph
3 Commits
Author SHA1 Message Date
Behdad Esfahbod 6f6ed4cd5c [vector] Share recycling metadata across renderers (#6480)
Use one hidden user-data key for vector blob metadata. A static key in
its header gives each renderer a different address, so a blob recycled
between renderers can retain a user-data entry for released metadata.

Clear in_replace after replace_buffer() returns, including when the
buffer stays at the same address and its destroy callback is skipped.
Otherwise the final destruction keeps the metadata allocation alive.

Exercise cross-renderer and in-place recycling in all four SVG/PDF draw
and paint paths. The cross-renderer case fails under ASan before the
fix. With the fix the sanitizer check and all 293 Meson tests pass, and
macOS leaks reports no leaks (five metadata allocations before clearing
the in_replace flag).

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-HAG1BPA1
and ordinary bug ANT-2026-YE77VHKY.

Assisted-by: OpenAI Codex
2026-10-30 15:03:23 -06:00
Behdad Esfahbod 9d044f792d [vector] Clear accumulated content after failed renders (#6363)
Early returns for missing extents, empty PDF paint output, or other
render failures retained content despite the automatic-clear contract.
Move clearing to scope guards in the common draw and paint render
entry points, covering every return for SVG and PDF.

Document the failure behavior. Extend the lifecycle regression to
compare subsequent output with fresh contexts for both formats,
including PDF resources and empty PDF paint renders. The regression
fails before the fix. The full Meson suite passes: 290 passed and one
existing test was skipped. The lifecycle test also passes as C99.

Fixes: https://github.com/harfbuzz/harfbuzz/issues/6358
Assisted-by: Codex
2026-10-10 18:33:11 -06:00
Behdad Esfahbod d45fa42c5a [vector] Restore reset defaults and clear PDF draw resources (#6355)
Vector reset omitted draw colors, paint background, SVG id prefixes,
and custom palette overrides. Restore these defaults while preserving
configuration across clear.

The PDF draw context also kept its opacity resource dictionary and
counter after clear, including automatic clearing after render.
Clear both with the accumulated output so later documents do not carry
resources from earlier renders.

Add regressions for SVG/PDF reset, configuration preservation, custom
palette overrides, and fresh-context PDF equivalence after explicit
clear, reset, and repeated rendering. All three regression groups fail
against the original implementation.

Tested with meson test -C build: 288 passed, 1 skipped, 0 failed.
The vector suite and the issue reproducer pass. The regression also
compiles and runs as C99 with -Wall -Wextra -Werror.

Fixes: https://github.com/harfbuzz/harfbuzz/issues/6342
Assisted-by: OpenAI Codex
2026-10-10 16:59:13 -06:00