hb_pair() preserves references to lvalue arguments. The alternate
collection callbacks returned pairs referencing their own by-value
parameters, so the next iterator stage read them after the call ended.
Pass each AlternateSubst glyph directly to the collector helper, which
already encodes its alternate index. This also keeps alternate_count
keyed by the original glyph. Return a value pair for SingleSubst format
1, as the subsetting path already does.
Cross-check collected maps against the per-glyph getter for four
SourceSansPro lookups. The alternate and both SingleSubst format 1
cases fail on the previous code; the format 2 control passes.
Testing: meson test -C build (292 passed; check-symbols skipped on
macOS). All five alternate API tests also pass under ASan and UBSan,
with stack-use-after-return detection enabled.
Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-N7S3EYU4.
Assisted-by: OpenAI Codex