From 9ddb3d0f24dde7f560f7db9dc9b8b1af7c03c637 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 30 Oct 2026 16:14:19 -0600 Subject: [PATCH 1/3] [VARC] Bound the glyph records walked during subsetting to the INDEX size closure_glyphs(), depend() and varc_subset_plan_t::collect_glyphs() each decode the full glyph record of every glyph id they reach, assuming every glyph has its own record. Nothing enforces that: CFFIndex::sanitize() accepts overlapping glyphRecords offsets, and a Coverage table may map many glyph ids to the same INDEX entry, so N glyph ids can resolve to one large record and the walk does N times that record's work -- quadratic in the font size (44 s for a 245 KB font), charged to no budget. In a well-formed table the records are disjoint and each glyph is visited once, so the bytes of all records walked cannot exceed the glyphRecords INDEX. Enforce exactly that invariant where the records are fetched, in all three walks, failing through each site's existing idiom. The remaining work is linear: a component decodes only if its record holds at least one byte per 64 counted axis values. In collect_glyphs() this also replaces the saturating sum and the post-loop data_size != UINT_MAX test, which a 64-bit build bypasses because hb_unsigned_add_saturate() returns size_t and the sum truncates into the unsigned data_size (a near-4 GiB total stored as a small value); the running total is now checked after every addition. Overlapping VARC records, already malformed per the CFF INDEX spec, now fail subsetting instead of being accepted; shaping and drawing are unaffected and valid VARC fonts subset to byte-identical output. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-71PGEDL2. Co-Authored-By: Claude Opus 4.8 --- src/OT/Var/VARC/VARC-subset.hh | 15 +++++++++---- src/OT/Var/VARC/VARC.cc | 19 +++++++++++++++- test/api/test-subset-varc.c | 41 ++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/src/OT/Var/VARC/VARC-subset.hh b/src/OT/Var/VARC/VARC-subset.hh index 9012c86d4..592c604a7 100644 --- a/src/OT/Var/VARC/VARC-subset.hh +++ b/src/OT/Var/VARC/VARC-subset.hh @@ -26,6 +26,11 @@ struct varc_subset_plan_t bool collect_glyphs () { const hb_set_t &glyphset = subset_context->plan->_glyphset_varced; + /* The records of a well-formed font do not overlap, so together they + * cannot outgrow their INDEX. As in VARC::closure_glyphs(). This also + * keeps the running total exact: a single saturating check after the + * loop can be bypassed by the sum truncating into unsigned data_size. */ + size_t records_size = source_records.get_size (); for (auto _ : + hb_zip (source_coverage, hb_range ((unsigned) source_records.count))) { @@ -39,13 +44,15 @@ struct varc_subset_plan_t return false; old_indices.push (index); new_gids.push (new_gid); - data_size = hb_unsigned_add_saturate (data_size, - source_records[index].length); + unsigned length = source_records[index].length; + if (unlikely (length > records_size)) + return false; + records_size -= length; + data_size += length; } } - return !old_indices.in_error () && !new_gids.in_error () && - data_size != UINT_MAX; + return !old_indices.in_error () && !new_gids.in_error (); } bool collect_indices () diff --git a/src/OT/Var/VARC/VARC.cc b/src/OT/Var/VARC/VARC.cc index c6a274c1e..af943137e 100644 --- a/src/OT/Var/VARC/VARC.cc +++ b/src/OT/Var/VARC/VARC.cc @@ -168,6 +168,13 @@ VARC::closure_glyphs (hb_set_t *glyphset) const if (unlikely (pending.in_error ())) return false; + /* Each glyph is visited once, and the records of a well-formed font do + * not overlap, so together they cannot outgrow their INDEX. A font with + * overlapping glyphRecords offsets, or Coverage ranges sharing an index, + * can otherwise make many gids resolve to one large record. */ + const CFF2Index &records = this+glyphRecords; + size_t records_size = records.get_size (); + while (pending) { hb_codepoint_t gid = pending.pop (); @@ -175,7 +182,10 @@ VARC::closure_glyphs (hb_set_t *glyphset) const unsigned index = (this+coverage).get_coverage (gid); if (index == NOT_COVERED) continue; - hb_ubytes_t record = (this+glyphRecords)[index]; + hb_ubytes_t record = records[index]; + if (unlikely (record.length > records_size)) + return false; + records_size -= record.length; while (record) { VarComponent::record_t component; @@ -201,11 +211,18 @@ void VARC::depend (hb_depend_data_builder_t *depend_data) const { const CFF2Index &records = this+glyphRecords; + size_t records_size = records.get_size (); /* As in closure_glyphs(). */ for (auto _ : + hb_zip (this+coverage, hb_range ((unsigned) records.count))) { hb_codepoint_t gid = _.first; hb_ubytes_t record = records[_.second]; + if (unlikely (record.length > records_size)) + { + depend_data->fail (); + return; + } + records_size -= record.length; while (record) { VarComponent::record_t component; diff --git a/test/api/test-subset-varc.c b/test/api/test-subset-varc.c index 2e4ec37cc..ced903485 100644 --- a/test/api/test-subset-varc.c +++ b/test/api/test-subset-varc.c @@ -524,6 +524,46 @@ test_subset_varc_passthrough_requires_retained_gids (void) hb_face_destroy (face); } +static void +test_subset_varc_overlapping_records (void) +{ + /* Three glyphs whose VARC records share bytes. Walking every record a + * glyph resolves to must not cost more than the glyphRecords INDEX. */ + static const char maxp_data[] = {0, 0, 0x50, 0, 0, 3}; + static const char coverages[][10] = { + /* Format 2, glyphs 0..2 -> records 0..2: caught by the closure. */ + {0, 2, 0, 1, 0, 0, 0, 2, 0, 0}, + /* Format 1, glyph 0 three times: caught by the table subsetter. */ + {0, 1, 0, 3, 0, 0, 0, 0, 0, 0}, + }; + char varc_data[] = { + 0, 1, 0, 0, /* version */ + 0, 0, 0, 24, /* coverage */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* varStore, conditionList, axisIndicesList */ + 0, 0, 0, 34, /* glyphRecords */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* coverage, filled in below */ + 0, 0, 0, 3, 1, /* INDEX: count 3, offSize 1 */ + 1, 31, 1, 31, /* records 0 and 2 are the same 30 bytes */ + 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, + 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, + }; + + for (unsigned i = 0; i < G_N_ELEMENTS (coverages); i++) + { + memcpy (varc_data + 24, coverages[i], sizeof (coverages[i])); + hb_face_t *face = hb_face_builder_create (); + HB_FACE_ADD_TABLE (face, "maxp", maxp_data); + HB_FACE_ADD_TABLE (face, "VARC", varc_data); + + hb_subset_input_t *input = hb_subset_input_create_or_fail (); + hb_set_add_range (hb_subset_input_glyph_set (input), 0, 2); + g_assert_null (hb_subset_or_fail (face, input)); + + hb_subset_input_destroy (input); + hb_face_destroy (face); + } +} + int main (int argc, char **argv) { @@ -540,5 +580,6 @@ main (int argc, char **argv) hb_test_add (test_subset_varc_instance_without_varc_glyphs); hb_test_add (test_subset_varc_can_be_explicitly_dropped_when_instancing); hb_test_add (test_subset_varc_passthrough_requires_retained_gids); + hb_test_add (test_subset_varc_overlapping_records); return hb_test_run (); } From 9f9055ee97d0c595358b5a441a7fde5e484f0f36 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 30 Oct 2026 16:26:05 -0600 Subject: [PATCH 2/3] [VARC] Charge MultiItemVariationStore delta lookups per region walked VarComponent::get_path_at() precharged axisValues.length x coords.length before MultiItemVariationStore::get_delta(), but the work that call does is one iteration per entry of the selected MultiVarData's regionIndices (up to 65535) plus, for each region not yet in the scalar cache, one evaluation per axis record (up to 65535). With no variation coordinates the precharge is zero, so a 148 KB font could drain the 2^24 glyph budget 65535 times too slowly: about 20 minutes of CPU for a single extents or draw call, reachable from plain hb_shape() on vertical text or fallback mark positioning. Thread the session budget (the same c.budget every other VARC charge site spends) through the three MultiItemVariationStore::get_delta() overloads into MultiVarData::get_delta(), which charges (1 + out.length) per listed region before the walk, and into SparseVariationRegion::evaluate(), which charges one unit per axis record before an uncached region is evaluated. This is the code that knows the real cost, so the charge is exact rather than an estimate. The three VARC call sites (axis-value deltas, transform deltas, and the MultiItemVarStoreInstancer used for component conditions) pass &c.budget and bail out once it goes negative, replacing the old values x coords estimates. All new parameters default to nullptr, so the instancing and subsetting callers are unaffected; no public API or ABI changes. A unit test in src/test-item-varstore.cc pins the exact per-region and per-axis charge and the bail-out once the budget is negative. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-RV2ORI9U. Co-Authored-By: Claude Opus 4.8 --- src/OT/Var/VARC/VARC.cc | 16 ++++++------- src/hb-ot-layout-common.hh | 48 +++++++++++++++++++++++++++----------- src/test-item-varstore.cc | 31 ++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 22 deletions(-) diff --git a/src/OT/Var/VARC/VARC.cc b/src/OT/Var/VARC/VARC.cc index af943137e..53f105256 100644 --- a/src/OT/Var/VARC/VARC.cc +++ b/src/OT/Var/VARC/VARC.cc @@ -396,8 +396,10 @@ VarComponent::get_path_at (const hb_varc_context_t &c, if (flags & (unsigned) flags_t::HAVE_CONDITION) { const auto &condition = (&VARC+VARC.conditionList)[component.condition_index]; - auto instancer = MultiItemVarStoreInstancer(&varStore, nullptr, coords, cache); + auto instancer = MultiItemVarStoreInstancer(&varStore, nullptr, coords, cache, &c.budget); show = condition.evaluate (coords.arrayZ, coords.length, &instancer); + if (unlikely (c.budget < 0)) + return hb_ubytes_t (); } // Axis values @@ -406,11 +408,10 @@ VarComponent::get_path_at (const hb_varc_context_t &c, if ((flags & (unsigned) flags_t::AXIS_VALUES_HAVE_VARIATION) && show && !axisValues.in_error ()) { - if (unlikely (!hb_budget_spend (c.budget, axisValues.length, - coords.length))) - return hb_ubytes_t (); varStore.get_delta (component.axis_values_var_idx, coords, - axisValues.as_array (), cache); + axisValues.as_array (), cache, &c.budget); + if (unlikely (c.budget < 0)) + return hb_ubytes_t (); } auto component_coords = coords; @@ -446,10 +447,9 @@ VarComponent::get_path_at (const hb_varc_context_t &c, transformValues[numTransformValues++] = (double) transform.name; VARC_PROCESS_TRANSFORM_COMPONENTS; #undef PROCESS_TRANSFORM_COMPONENT - if (unlikely (!hb_budget_spend (c.budget, numTransformValues, - coords.length))) + varStore.get_delta (transformVarIdx, coords, hb_array (transformValues, numTransformValues), cache, &c.budget); + if (unlikely (c.budget < 0)) return hb_ubytes_t (); - varStore.get_delta (transformVarIdx, coords, hb_array (transformValues, numTransformValues), cache); numTransformValues = 0; #define PROCESS_TRANSFORM_COMPONENT(shift, type, flag, name) \ if (flags & (unsigned) flags_t::flag) \ diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 19e0f4e43..8eb7d120f 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -2953,10 +2953,15 @@ _hb_avar2_region_is_dead (const hb_hashmap_t &axis_tuples, struct SparseVariationRegion { - float evaluate (const int *coords, unsigned int coord_len) const + float evaluate (const int *coords, unsigned int coord_len, + int64_t *budget = nullptr) const { float v = 1.f; unsigned int count = axes.len; + /* Each region is walked per uncached delta; charge its axis records. */ + if (budget && + unlikely (!hb_budget_spend (*budget, HB_BUDGET_1, count))) + return 0.; for (unsigned int i = 0; i < count; i++) { float factor = (this+axes[i]).evaluate (coords, coord_len); @@ -2997,7 +3002,8 @@ struct SparseVarRegionList HB_ALWAYS_INLINE float evaluate (unsigned int region_index, const int *coords, unsigned int coord_len, - hb_scalar_cache_t *cache = nullptr) const + hb_scalar_cache_t *cache = nullptr, + int64_t *budget = nullptr) const { if (unlikely (region_index >= regions.len)) return 0.; @@ -3008,7 +3014,7 @@ struct SparseVarRegionList const SparseVariationRegion ®ion = this+regions[region_index]; - v = region.evaluate (coords, coord_len); + v = region.evaluate (coords, coord_len, budget); if (cache) cache->set (region_index, v); @@ -3452,18 +3458,24 @@ struct MultiVarData const int *coords, unsigned int coord_count, const SparseVarRegionList ®ions, hb_array_t out, - hb_scalar_cache_t *cache = nullptr) const + hb_scalar_cache_t *cache = nullptr, + int64_t *budget = nullptr) const { auto &deltaSets = get_delta_sets (); auto values_iter = deltaSets.fetcher (inner); unsigned regionCount = regionIndices.len; + /* Every listed region is visited, and can add to every value. */ + if (budget && + unlikely (!hb_budget_spend (*budget, HB_BUDGET_1 + out.length, + regionCount))) + return; unsigned skip = 0; for (unsigned regionIndex = 0; regionIndex < regionCount; regionIndex++) { float scalar = regions.evaluate (regionIndices.arrayZ[regionIndex], coords, coord_count, - cache); + cache, budget); // We skip lazily. Helps with the tail end. if (scalar == 0.0f) skip += out.length; @@ -3878,7 +3890,8 @@ struct MultiItemVariationStore void get_delta (unsigned int outer, unsigned int inner, const int *coords, unsigned int coord_count, hb_array_t out, - hb_scalar_cache_t *cache = nullptr) const + hb_scalar_cache_t *cache = nullptr, + int64_t *budget = nullptr) const { #ifdef HB_NO_VAR return; @@ -3891,28 +3904,32 @@ struct MultiItemVariationStore coords, coord_count, this+regions, out, - cache); + cache, budget); } public: + /* If BUDGET is given, the work is charged to it; once it is exhausted + * (negative), OUT is unspecified and the caller should bail out. */ void get_delta (unsigned int index, const int *coords, unsigned int coord_count, hb_array_t out, - hb_scalar_cache_t *cache = nullptr) const + hb_scalar_cache_t *cache = nullptr, + int64_t *budget = nullptr) const { unsigned int outer = index >> 16; unsigned int inner = index & 0xFFFF; - get_delta (outer, inner, coords, coord_count, out, cache); + get_delta (outer, inner, coords, coord_count, out, cache, budget); } void get_delta (unsigned int index, hb_array_t coords, hb_array_t out, - hb_scalar_cache_t *cache = nullptr) const + hb_scalar_cache_t *cache = nullptr, + int64_t *budget = nullptr) const { return get_delta (index, coords.arrayZ, coords.length, out, - cache); + cache, budget); } bool sanitize (hb_sanitize_context_t *c) const @@ -4261,8 +4278,10 @@ struct MultiItemVarStoreInstancer MultiItemVarStoreInstancer (const MultiItemVariationStore *varStore, const DeltaSetIndexMap *varIdxMap, hb_array_t coords, - hb_scalar_cache_t *cache = nullptr) : - varStore (varStore), varIdxMap (varIdxMap), coords (coords), cache (cache) + hb_scalar_cache_t *cache = nullptr, + int64_t *budget = nullptr) : + varStore (varStore), varIdxMap (varIdxMap), coords (coords), cache (cache), + budget (budget) { if (!varStore) varStore = &Null(MultiItemVariationStore); @@ -4288,7 +4307,7 @@ struct MultiItemVarStoreInstancer varIdx += offset; if (varIdxMap) varIdx = varIdxMap->map (varIdx); - varStore->get_delta (varIdx, coords, out, cache); + varStore->get_delta (varIdx, coords, out, cache, budget); } else for (unsigned i = 0; i < out.length; i++) @@ -4299,6 +4318,7 @@ struct MultiItemVarStoreInstancer const DeltaSetIndexMap *varIdxMap; hb_array_t coords; hb_scalar_cache_t *cache; + int64_t *budget; }; diff --git a/src/test-item-varstore.cc b/src/test-item-varstore.cc index 19a79b62d..b960e7aab 100644 --- a/src/test-item-varstore.cc +++ b/src/test-item-varstore.cc @@ -395,6 +395,36 @@ test_condition_delta_precision () bytes.fini (); } +static void +test_multi_instancer_budget () +{ + const char store_data[] = + "\x00\x01" "\x00\x00\x00\x0c" "\x00\x01" "\x00\x00\x00\x22" // Store + "\x00\x00\x00\x01" "\x00\x00\x00\x08" // SparseVarRegionList + "\x00\x01" "\x00\x00\x00\x06" // SparseVariationRegion + "\x00\x00" "\x00\x00" "\x40\x00" "\x40\x00" // SparseVarRegionAxis + "\x01" "\x00\x02" "\x00\x00" "\x00\x00" "\x00\x00\x00\x0b" // MultiVarData + "\x00\x00\x00\x01" "\x01" "\x01\x04" "\x01\x01\x02"; // TupleList + const auto &store = *reinterpret_cast (store_data); + int coords[] = {16384}; + OT::hb_scalar_cache_t static_cache; + auto *cache = store.create_cache (&static_cache); + hb_always_assert (cache == &static_cache); + int64_t budget = 9; + OT::MultiItemVarStoreInstancer instancer (&store, nullptr, hb_array (coords), cache, &budget); + // Each delta is charged per region listed by its MultiVarData, for the + // visit and for each value; and per axis of each region not cached yet. + hb_always_assert (instancer[0] == 3.); + hb_always_assert (budget == 4); + hb_always_assert (instancer[OT::VarIdx::NO_VARIATION] == 0.); + hb_always_assert (budget == 4); + hb_always_assert (instancer[0] == 3.); + hb_always_assert (budget == 0); + hb_always_assert (instancer[0] == 0.); + hb_always_assert (budget < 0); + OT::MultiItemVariationStore::destroy_cache (cache, &static_cache); +} + static void test_failed_encoding () { @@ -466,4 +496,5 @@ main (int argc, char **argv) test_failed_encoding (); test_accumulated_delta_widths (); test_condition_delta_precision (); + test_multi_instancer_budget (); } From 9c840213917950cb126df97e37af2c566fa82494 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 30 Oct 2026 16:33:20 -0600 Subject: [PATCH 3/3] [VARC] Charge VARC component condition evaluation to the work budget VarComponent::get_path_at() paid a flat HB_BUDGET_4 per component and then evaluated the component's Condition tree for free. ConditionAnd and ConditionOr children are offsets that may all point at the same subtree, so the evaluated size of a tree is not tied to its encoded size: a 1.4 KB ConditionList expands to 51,001 leaf visits per component, and a 143-byte chain of two-child ConditionAnd nodes to 65,535 node visits, while the glyph budget still admits hundreds of thousands of such components. A sub-20 KB font could keep one glyph extents or draw call busy for minutes, reachable from hb_shape() on vertical text or combining marks. Condition::evaluate() is a template shared with FeatureVariations in GSUB/GPOS, which is evaluated once while building a shape or subset plan and has no rendering budget, so route the charge through the instancer: MultiItemVarStoreInstancer::charge_condition() spends HB_BUDGET_1 from the live budget threaded in for the delta lookups, while ItemVarStoreInstancer::charge_condition() is a no-op. Condition:: evaluate() charges one unit per node visited, so every node is counted even when an And/Or's children share one subtree, and returns false once the charge fails; the VARC caller already bails when c.budget goes negative right after the evaluation. The instancer && guard keeps the null-instancer callers (e.g. src/test-serialize.cc) safe. A font whose conditional components do pathological amounts of condition work now exhausts the glyph budget and renders incomplete output instead of running for minutes; ordinary fonts spend a few extra units per conditional component, and GSUB/GPOS condition evaluation is unchanged. A unit test in src/test-item-varstore.cc pins the per-node charge, including shared subtrees, and the bail-out once the budget is negative. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-U1J54XX5. Co-Authored-By: Claude Opus 4.8 --- src/hb-ot-layout-common.hh | 14 ++++++++++++++ src/test-item-varstore.cc | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 8eb7d120f..ba274a7f3 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -4250,6 +4250,10 @@ struct ItemVarStoreInstancer double get_condition_delta (uint32_t varIdx) const { return get_delta (varIdx); } + /* FeatureVariations conditions are evaluated once while building a shape + * or subset plan, not under a rendering work budget. */ + bool charge_condition () const { return true; } + template Float get_delta (uint32_t varIdx, unsigned short offset = 0) const { @@ -4292,6 +4296,11 @@ struct MultiItemVarStoreInstancer double get_condition_delta (uint32_t varIdx) const { return (double) (*this)[varIdx]; } + /* Condition trees are evaluated per VARC component visit, so they draw + * on the renderer's live work budget when one is attached. */ + bool charge_condition () const + { return !budget || hb_budget_spend (*budget, HB_BUDGET_1); } + double operator[] (uint32_t varIdx) const { double v = 0; @@ -4700,6 +4709,11 @@ struct Condition bool evaluate (const int *coords, unsigned int coord_len, Instancer *instancer) const { + /* And/Or children are offsets that may all share one subtree, so the + * evaluated size of a condition tree is not tied to its encoded size. + * Charge every node visited; the guard keeps a null instancer safe. */ + if (unlikely (instancer && !instancer->charge_condition ())) return false; + switch (u.format.v) { /* A null condition offset resolves to the nil Condition, whose reserved * format 0 represents the True condition required by the specification. */ diff --git a/src/test-item-varstore.cc b/src/test-item-varstore.cc index b960e7aab..7e0ca2eed 100644 --- a/src/test-item-varstore.cc +++ b/src/test-item-varstore.cc @@ -425,6 +425,38 @@ test_multi_instancer_budget () OT::MultiItemVariationStore::destroy_cache (cache, &static_cache); } +static void +test_condition_budget () +{ + static const unsigned char store_data[] = { + 0, 1, 0, 0, 0, 12, 0, 1, 0, 0, 0, 26, /* MultiItemVariationStore */ + 0, 0, 0, 2, 0, 0, 0, 12, 0, 0, 0, 12, /* SparseVarRegionList */ + 0, 0, /* SparseVariationRegion */ + 1, 0, 2, 0, 0, 0, 1, 0, 0, 0, 11, /* MultiVarData */ + 0, 0, 0, 1, 1, 1, 4, 1, 1, 2, /* TupleList */ + }; + static const unsigned char condition_data[] = { + 0, 3, 3, 0, 0, 12, 0, 0, 12, 0, 0, 12, /* ConditionAnd */ + 0, 2, 0xFF, 0xFE, 0, 0, 0, 0, /* ConditionValue */ + }; + const auto &store = *reinterpret_cast (store_data); + const auto &condition = *reinterpret_cast (condition_data); + + OT::MultiItemVarStoreInstancer unbudgeted (&store, nullptr, hb_array_t ()); + hb_always_assert (unbudgeted.get_condition_delta (0) == 3.); + hb_always_assert (condition.evaluate (nullptr, 0, &unbudgeted)); + + // Every node visited is charged one unit, even when the And's three + // children share one subtree; each value leaf fetches a delta charged per + // region its MultiVarData sums over ((1 + out.length) x 2 regions). + int64_t budget = 1 + 3 * (1 + (1 + 1) * 2); + OT::MultiItemVarStoreInstancer instancer (&store, nullptr, hb_array_t (), nullptr, &budget); + hb_always_assert (condition.evaluate (nullptr, 0, &instancer)); + hb_always_assert (budget == 0); + hb_always_assert (!condition.evaluate (nullptr, 0, &instancer)); + hb_always_assert (budget < 0); +} + static void test_failed_encoding () { @@ -497,4 +529,5 @@ main (int argc, char **argv) test_accumulated_delta_widths (); test_condition_delta_precision (); test_multi_instancer_budget (); + test_condition_budget (); }