From d15260ca9580d04d04829eefbcb239112afef2ed Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 25 Jun 2022 19:53:11 -0600 Subject: [PATCH] [gpos] Limit recursion depth in propagate_attachment_offsets() Fixes https://github.com/harfbuzz/harfbuzz/issues/2927 --- src/hb-ot-layout-gpos-table.hh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index b0f6eb77f..f476397e3 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -3022,7 +3022,8 @@ static void propagate_attachment_offsets (hb_glyph_position_t *pos, unsigned int len, unsigned int i, - hb_direction_t direction) + hb_direction_t direction, + unsigned nesting_level = HB_MAX_NESTING_LEVEL) { /* Adjusts offsets of attached glyphs (both cursive and mark) to accumulate * offset of glyph they are attached to. */ @@ -3037,7 +3038,10 @@ propagate_attachment_offsets (hb_glyph_position_t *pos, if (unlikely (j >= len)) return; - propagate_attachment_offsets (pos, len, j, direction); + if (unlikely (!nesting_level)) + return; + + propagate_attachment_offsets (pos, len, j, direction, nesting_level - 1); assert (!!(type & ATTACH_TYPE_MARK) ^ !!(type & ATTACH_TYPE_CURSIVE));