Skip to content

Commit 5c6ccc1

Browse files
behdaddahlstrom-g
authored andcommitted
[layout] Limit how far we skip when looking back
See comments. (cherry picked from commit 85be877925ddbf34f74a1229f3ca1716bb6170dc)
1 parent cfb7103 commit 5c6ccc1

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎third_party/harfbuzz-ng/src/src/hb-ot-layout-gsubgpos.hh‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,13 @@ struct hb_ot_apply_context_t :
597597
unsigned stop = num_items - 1;
598598
if (c->buffer->flags & HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT)
599599
stop = 1 - 1;
600+
601+
/* When looking back, limit how far we search; this function is mostly
602+
* used for looking back for base glyphs when attaching marks. If we
603+
* don't limit, we can get O(n^2) behavior where n is the number of
604+
* consecutive marks. */
605+
stop = (unsigned) hb_max ((int) stop, (int) idx - HB_MAX_CONTEXT_LENGTH);
606+
600607
while (idx > stop)
601608
{
602609
idx--;

0 commit comments

Comments
 (0)