diff --git a/src/hb-ot-cff-common.hh b/src/hb-ot-cff-common.hh index 2c4b1c6c0..a544fea1b 100644 --- a/src/hb-ot-cff-common.hh +++ b/src/hb-ot-cff-common.hh @@ -68,11 +68,15 @@ struct CFFIndex hb_requires (hb_is_iterable (Iterable))> bool serialize (hb_serialize_context_t *c, const Iterable &iterable, - unsigned data_size = (unsigned) -1) + const unsigned *p_data_size = nullptr) { TRACE_SERIALIZE (this); - if (data_size == (unsigned) -1) + unsigned data_size; + if (p_data_size) + data_size = *p_data_size; + else total_size (iterable, &data_size); + auto it = hb_iter (iterable); if (unlikely (!serialize_header (c, +it, data_size))) return_trace (false); unsigned char *ret = c->allocate_size (data_size, false); diff --git a/src/hb-subset-cff1.cc b/src/hb-subset-cff1.cc index 1541b542f..fb93448dc 100644 --- a/src/hb-subset-cff1.cc +++ b/src/hb-subset-cff1.cc @@ -831,7 +831,7 @@ OT::cff1::accelerator_subset_t::serialize (hb_serialize_context_t *c, return false; auto *cs = c->start_embed (); - if (likely (cs->serialize (c, plan.subset_charstrings, data_size))) + if (likely (cs->serialize (c, plan.subset_charstrings, &data_size))) plan.info.char_strings_link = c->pop_pack (false); else { diff --git a/src/hb-subset-cff2.cc b/src/hb-subset-cff2.cc index bdae27c76..3c52fb9c2 100644 --- a/src/hb-subset-cff2.cc +++ b/src/hb-subset-cff2.cc @@ -566,7 +566,7 @@ OT::cff2::accelerator_subset_t::serialize (hb_serialize_context_t *c, return false; auto *cs = c->start_embed (); - if (likely (cs->serialize (c, plan.subset_charstrings, data_size))) + if (likely (cs->serialize (c, plan.subset_charstrings, &data_size))) plan.info.char_strings_link = c->pop_pack (false); else {