The per-text limits max_len/max_ops are set by hb_buffer_t::enter() and
reset by leave(), but since e246723f0 only hb_shape_full() called them,
so the public hb_shape_plan_execute() ran the shapers with the idle
defaults (0x3FFFFFFF glyphs / 0x1FFFFFFF ops). A client that executes a
plan itself could be made to allocate gigabytes or spend seconds of CPU
on a single character. A reused buffer also kept its spent op budget
across executions, silently skipping nested lookups afterwards.
Move the enter()/leave() pair from hb_shape_full() into the
HB_SHAPER_EXECUTE step of _hb_shape_plan_execute_internal(), the single
point every public path reaches the shapers through, so each call gets a
fresh allowance. It runs after the empty-buffer early return, so the
immutable empty buffer is never written.
enter() now runs on every shape, so guard against discarding a limit
that internal code narrowed below the idle default before shaping (the
output-growth fault injection in src/test-graphite2-buffer.cc sets
max_len that way): compute the per-text limit as before, but keep the
stricter value when the current limit is already below the default.
Public paths always arrive at the idle defaults (from hb_buffer_create()
or leave()), so they get exactly the computed per-text limit as today;
reused buffers are refilled because leave() restores the defaults first.
hb_shape_full()'s VERIFY pass now runs after leave(), which is harmless:
it reshapes fragment copies via hb_shape_full() (which install their own
limits) and does not read max_len/max_ops. No API/ABI change.
A regression test in test/api/test-shape-plan.c asserts that
hb_shape_plan_execute() yields the same buffer length as hb_shape().
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-SUMXXLXH.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Use has_nonzero_coords when creating a shaping plan, and treat explicit
all-zero coordinates as an empty location in ItemVarStoreInstancer.
A constant GDEF delta then cannot change a condition at the default
instance, matching OFF section 7.1 and the condition's default field.
Keep the Boolean result in the stored int16 default when partial
instancing moves an oversized condition value into a private bias row.
Only the excess belongs in that row, since default instances ignore it.
Add a regression for empty versus explicit default plan keys and shaping
across default, varied, and default locations. Existing subset precision
tests cover the private bias and repeated instancing.
Validation: all 290 Meson test groups pass with experimental APIs enabled.
Assisted-by: Codex
Extend the lookup-variation fixture with a GDEF ItemVariationStore-backed
ConditionValue and a GPOS conditional positioning lookup. This covers
variation-index evaluation, GPOS shaping, and lookup collection while
reusing the existing partial-instancing checks.
Tested with the full Meson suite and OTS validation of the fixture.
Assisted-by: OpenAI Codex <codex@openai.com>
Reduce LookupVariationRecord conditions to false, true, or a residual
condition when axes are pinned or restricted. Fold compound AND, OR,
and NOT conditions, remap value-condition variation indices, and emit a
constant condition when a surviving lookup becomes unconditional.
Extend the test font with a second axis and all condition formats so the
subset tests cover structural, full, and partial instancing behavior.
Tested with the full Meson test suite, targeted Clang HB_NO_VAR and GCC
builds, and OTS validation of the fixture.
Assisted-by: OpenAI Codex <codex@openai.com>
Parse and sanitize the FeatureVariations 1.1 lookup-oriented records.
Resolve their effective lookup sets while constructing the shape-plan
key so cache entries remain exact without retaining raw coordinates.
Handle ADD_DEFAULT_LOOKUPS, multiple matching conditions, and the
interaction with version 1.0 feature substitutions. Keep the existing
public FeatureVariations query API behavior unchanged.
Tested with the full Meson test suite.
Assisted-by: OpenAI Codex <codex@openai.com>
Simplify the API by returning only feature tags. The users of this API
would be interested only in feature enabled by default and whether the
feature is globally or partially enabled wouldn’t be of much interest in
that case. For user features, the user of the API already have full
access to them.
This should get the features on a shape plan after executing it.
Initially I wanted to return an array of tags, but then there can be
user features that are not enabled globally, so I thought returning
hb_feature_t with value and range would be better. There is a TODO since
I couldn’t figure out how to get the value and range from the feature
mask. But also it may be overkill and a simple boolean indicating wither
it is a global feature or not would be enough.
I wounder also what should happen to non-user features that are applied
selectively, like init or medi, does ot make sense to indicate whether
they are global or not?
This is inspired by the discussion in:
https://github.com/fontforge/fontforge/pull/5522#pullrequestreview-2574321449,
but it might be useful to other HarfBuzz users.