[GSUB] Fix context_length handling in Ligature too

This commit is contained in:
Behdad Esfahbod 2009-05-18 04:21:53 -04:00
parent 47958dea21
commit 122f21fb9a
2 changed files with 7 additions and 7 deletions

View File

@ -318,14 +318,13 @@ struct Ligature {
unsigned int i, j; unsigned int i, j;
unsigned int count = component.len; unsigned int count = component.len;
unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
if (HB_UNLIKELY (buffer->in_pos + count > buffer->in_length || if (HB_UNLIKELY (buffer->in_pos + count > end))
context_length < count)) return false;
return false; /* Not enough glyphs in input or context */
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++) { for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++) {
while (!_hb_ot_layout_check_glyph_property (layout, IN_ITEM (j), lookup_flag, &property)) { while (!_hb_ot_layout_check_glyph_property (layout, IN_ITEM (j), lookup_flag, &property)) {
if (HB_UNLIKELY (j + count - i == buffer->in_length)) if (HB_UNLIKELY (j + count - i == end))
return false; return false;
j++; j++;
} }

View File

@ -221,7 +221,7 @@ static inline bool context_lookup (LOOKUP_ARGS_DEF,
{ {
/* First guess */ /* First guess */
if (HB_UNLIKELY (buffer->in_pos + inputCount > buffer->in_length || if (HB_UNLIKELY (buffer->in_pos + inputCount > buffer->in_length ||
context_length < inputCount)) inputCount > context_length))
return false; return false;
return match_input (LOOKUP_ARGS, return match_input (LOOKUP_ARGS,
@ -435,7 +435,8 @@ static inline bool chain_context_lookup (LOOKUP_ARGS_DEF,
{ {
/* First guess */ /* First guess */
if (HB_UNLIKELY (buffer->out_pos < backtrackCount || if (HB_UNLIKELY (buffer->out_pos < backtrackCount ||
buffer->in_pos + inputCount + lookaheadCount > buffer->in_length)) buffer->in_pos + inputCount + lookaheadCount > buffer->in_length ||
inputCount + lookaheadCount > context_length))
return false; return false;
unsigned int offset; unsigned int offset;