Files
harfbuzz/test/api
nussaibah shaikh 3fff90528d clamp variable advance before unsigned conversion (#6395)
get_advance_with_var_unscaled adds the HVAR/VVAR advance delta to the
base advance and returns the sum as unsigned. The delta from
ItemVariationStore::get_delta is an unbounded float, so an HVAR whose
item-variation store uses long-word (int32) deltas across several
regions that all peak at the axis extreme can make advance + roundf
(delta) exceed the unsigned range; converting that float to unsigned is
then undefined behavior (UBSan float-cast-overflow), and hb_max (0.0f,
NaN) would likewise pass NaN to the conversion. Reached from the public
hb_font_get_glyph_h_advance / v_advance on a variable font.

Clamp the accumulated value into the unsigned range with hb_clamp_to
before returning, matching the saturation already used for the
variation-derived glyph-extents arithmetic. Valid advances are
unchanged. The template is shared by hmtx/HVAR and vmtx/VVAR, so all
three advance sites are covered.

Add a regression test under test/api driving a crafted long-word HVAR;
it reports float-cast-overflow under the sanitizers job without the fix
and passes with it. The full meson test suite passes.
2026-10-14 10:51:09 -06:00
..
2025-04-06 18:08:50 -06:00
2026-07-30 19:02:25 -06:00
2026-08-25 14:47:33 -06:00
2026-09-04 14:14:49 -06:00
2026-07-31 04:31:26 +03:00
2025-04-05 22:37:10 -06:00
2020-01-31 16:37:30 -05:00
2020-01-15 13:36:01 -08:00
2025-06-08 13:43:27 +03:00