From e177de31b0df7f3325f0f0a162dada2b425fa18a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 12 Aug 2026 17:24:22 -0600 Subject: [PATCH] [GPOS] Saturate reversed cursive offsets Reversing a cursive attachment chain negates the child's cross-stream offset. Saturate that negation so INT_MIN produces INT_MAX instead of signed-overflow undefined behavior. This is part of the complete position-overflow fix for issue #6151. Testing: meson test -C build --print-errorlogs Assisted-by: Codex --- src/OT/Layout/GPOS/CursivePosFormat1.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OT/Layout/GPOS/CursivePosFormat1.hh b/src/OT/Layout/GPOS/CursivePosFormat1.hh index 3e2c15d56..41c1f4baa 100644 --- a/src/OT/Layout/GPOS/CursivePosFormat1.hh +++ b/src/OT/Layout/GPOS/CursivePosFormat1.hh @@ -82,9 +82,9 @@ reverse_cursive_minor_offset (hb_glyph_position_t *pos, reverse_cursive_minor_offset (pos, len, j, direction, new_parent); if (HB_DIRECTION_IS_HORIZONTAL (direction)) - pos[j].y_offset = -pos[i].y_offset; + pos[j].y_offset = hb_saturate_neg (pos[i].y_offset); else - pos[j].x_offset = -pos[i].x_offset; + pos[j].x_offset = hb_saturate_neg (pos[i].x_offset); pos[j].attach_chain() = reversed_chain; pos[j].attach_type() = type;