mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 06:21:16 +01:00
When partially instancing a CFF2 font, the blend rewriters in hb-subset-cff2.cc pass each old delta row through the region transform and store the result with (int) round (transform_delta (...)). transform_delta accumulates in double with no bound. Private DICT operands can be BCD reals of any magnitude, so a StdVW blend delta of 1e12 yields about 3.7e11 at wght=300:600, and the double-to-int conversion is undefined behavior (UBSan float-cast-overflow in cff2_private_dict_blend_opset_t::rewrite_blends). Saturate with hb_clamp_to<int>, as number_t::to_int already does. The charstring blend rewriter uses the same expression and gets the same clamp. Charstring operands are bounded by the 16.16 range, so that site is not known to overflow in practice. Results that fit in int are unchanged. Add a regression test to test-instance-cff2 with a fixture generated from AdobeVFPrototype.abc.otf. Under UBSAN_OPTIONS=halt_on_error=1 it fails before the fix and passes after. The full Meson suite passes under ASan+UBSan (290 ok). Assisted-by: Claude