From 91b07e93d4a4367f432249aff4bd6f98d4c7f2eb Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 12 Aug 2026 17:31:45 -0600 Subject: [PATCH] [trak] Saturate tracking advances AAT tracking adds the selected tracking value to the first glyph of each grapheme. Saturate horizontal and vertical advance updates so an extreme scale or repeated application cannot overflow hb_position_t. This is part of the complete position-overflow fix for issue #6151. Testing: meson test -C build --print-errorlogs Assisted-by: Codex --- src/hb-aat-layout-trak-table.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh index 14a7d5794..104a346d4 100644 --- a/src/hb-aat-layout-trak-table.hh +++ b/src/hb-aat-layout-trak-table.hh @@ -230,13 +230,13 @@ struct trak { hb_position_t advance_to_add = get_h_tracking (c->font, track); foreach_grapheme (buffer, start, end) - buffer->pos[start].x_advance += advance_to_add; + buffer->pos[start].x_advance = hb_saturate_add (buffer->pos[start].x_advance, advance_to_add); } else { hb_position_t advance_to_add = get_v_tracking (c->font, track); foreach_grapheme (buffer, start, end) - buffer->pos[start].y_advance += advance_to_add; + buffer->pos[start].y_advance = hb_saturate_add (buffer->pos[start].y_advance, advance_to_add); } return_trace (true);