diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index e055239d7..36f6dd405 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -988,7 +988,7 @@ static inline bool apply_lookup (hb_apply_context_t *c, /* end can't go back past the current match position. * Note: this is only true because we do NOT allow MultipleSubst * with zero sequence len. */ - end = MAX ((int) match_positions[idx] + 1, int (end) + delta); + end = MAX (MIN((int) match_positions[idx] + 1, (int) new_len), int (end) + delta); unsigned int next = idx + 1; /* next now is the position after the recursed lookup. */