From 05d7cb5fecdbb2f1c300bd497d1fb4473a322eef Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 12 Aug 2026 17:45:00 -0600 Subject: [PATCH] [font] Clamp synthetic emboldening strength Computing synthetic emboldening strength could negate INT_MIN through abs() and convert an out-of-range float to int32_t. Use floating-point absolute value and clamp the rounded result to a valid position. This is part of the complete position-overflow fix for issue #6151. Testing: meson test -C build --print-errorlogs Assisted-by: Codex --- src/hb-font.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hb-font.hh b/src/hb-font.hh index 54c73a721..ccc88338a 100644 --- a/src/hb-font.hh +++ b/src/hb-font.hh @@ -1159,8 +1159,8 @@ struct hb_font_t is_synthetic = x_embolden || y_embolden || slant; - x_strength = roundf (abs (x_scale) * x_embolden); - y_strength = roundf (abs (y_scale) * y_embolden); + x_strength = hb_clamp_to (roundf (fabsf ((float) x_scale) * x_embolden)); + y_strength = hb_clamp_to (roundf (fabsf ((float) y_scale) * y_embolden)); slant_xy = y_scale ? slant * x_scale / y_scale : 0.f;