Skip to content

Commit 85be877

Browse files
committed
[layout] Limit how far we skip when looking back
See comments.
1 parent d18fd3f commit 85be877

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: src/hb-ot-layout-gsubgpos.hh

+7
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,13 @@ struct hb_ot_apply_context_t :
578578
unsigned stop = num_items - 1;
579579
if (c->buffer->flags & HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT)
580580
stop = 1 - 1;
581+
582+
/* When looking back, limit how far we search; this function is mostly
583+
* used for looking back for base glyphs when attaching marks. If we
584+
* don't limit, we can get O(n^2) behavior where n is the number of
585+
* consecutive marks. */
586+
stop = (unsigned) hb_max ((int) stop, (int) idx - HB_MAX_CONTEXT_LENGTH);
587+
581588
while (idx > stop)
582589
{
583590
idx--;

0 commit comments

Comments
 (0)