mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 14:31:10 +01:00
Anchor coordinates are scaled as float, and apply_cursive_attachment() and the mark attachment code converted them to hb_position_t with a plain cast or an implicit conversion. A value out of range for the target type makes that conversion undefined; on x86 it gives INT32_MIN. #6154 made the additions around these conversions saturate, but not the conversions themselves. With NotoNastaliqUrdu-Regular.ttf at a scale of INT32_MAX, a cursive anchor scales to 2.23e9, and the glyph ended up with an x_advance of -2147483648. Convert with hb_clamp_to(), and negate the cursive cross-direction offsets with hb_saturate_neg(), since they can now be INT32_MIN. Results that fit do not change. Tested with test-shape under UBSan: the new test fails on the base commit at CursivePosFormat1.hh:141 and passes here. No test reaches the two conversions in MarkArray.hh; they are changed to match. Assisted-by: Claude