Files
harfbuzz/test/vector
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
..

Adding tests

test/vector validates hb-vector CLI output by comparing exact stdout with golden files.

Test file format (data/tests/*.tests)

Each non-empty, non-comment line has 4 semicolon-separated fields:

font-file;options;unicodes;expected-file
  • font-file: relative to the .tests file (or absolute path).
  • options: shell-split arguments passed to hb-vector.
  • unicodes: Unicode sequence, using shape-style codepoint format (for example U+0061,U+0062,U+0063).
  • expected-file: path to golden output, relative to the .tests file. This is also used as the TAP test name.

Example:

../../../api/fonts/Roboto-Regular.abc.ttf;--font-size=64;U+0061,U+0062,U+0063;../expected/basic/reuse-svg.svg

Running vector tests

In an in-tree build:

meson test -C build-default -v --suite vector

Updating expected output

Regenerate a golden file with the current hb-vector binary and replace the file under data/expected/.

Recording a new test case

Use record-test.sh:

./record-test.sh -o data/tests/basic.tests --test-name reuse-svg ../../build-default/util/hb-vector ../api/fonts/Roboto-Regular.abc.ttf --font-size=64 abc

It subsets the input font, verifies subset-vs-original rendering with hb-view, stores the subset font under ../fonts/<sha1>.ttf (relative to the target .tests file), writes expected output under ../expected/<tests-stem>/<test-name>.<ext> by default (unless --expected-dir or --expected-file is provided), and appends one test line to the target .tests file. hb-shape, hb-view, and hb-subset are resolved as sibling executables next to the provided hb-vector binary. The emitted test line uses Unicode codepoint input in the unicodes field.