[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 <codex@openai.com>
This commit is contained in:
Behdad Esfahbod committed 2026-08-12 17:24:22 -06:00
1 parent 291b7ef1e0
commit e177de31b0
1 file changed
+2 -2
+2 -2
View File
@@ -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;