From 19fc24f268b985d30971307ac2055622d11cb21f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 17 May 2009 09:45:32 -0400 Subject: [PATCH] [HB] Couple size checks --- src/hb-ot-layout-gsub-private.h | 7 +++++-- src/hb-ot-layout-gsubgpos-private.h | 4 ++-- src/hb-ot-layout-open-private.h | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/hb-ot-layout-gsub-private.h b/src/hb-ot-layout-gsub-private.h index 74f4e3649..89f4fd8e0 100644 --- a/src/hb-ot-layout-gsub-private.h +++ b/src/hb-ot-layout-gsub-private.h @@ -346,10 +346,10 @@ struct Ligature { value it is later possible to check whether a specific component value really belongs to a given ligature. */ - for ( i = 0; i < count - 1; i++ ) + for ( i = 1; i < count; i++ ) { while (!_hb_ot_layout_check_glyph_property (layout, IN_CURITEM(), lookup_flag, &property)) - _hb_buffer_add_output_glyph (buffer, IN_CURGLYPH(), i, lig_id); + _hb_buffer_add_output_glyph (buffer, IN_CURGLYPH(), i - 1, lig_id); (buffer->in_pos)++; } @@ -834,6 +834,9 @@ struct SubstLookup : Lookup { bool ret = false; + if (HB_UNLIKELY (!buffer->in_length)) + return false; + if (HB_LIKELY (!is_reverse ())) { /* in/out forward substitution */ diff --git a/src/hb-ot-layout-gsubgpos-private.h b/src/hb-ot-layout-gsubgpos-private.h index b53701522..033078b9c 100644 --- a/src/hb-ot-layout-gsubgpos-private.h +++ b/src/hb-ot-layout-gsubgpos-private.h @@ -113,7 +113,7 @@ static inline bool context_lookup (LOOKUP_ARGS_DEF, const LookupRecord *record = lookupRecord; for (i = 0; i < count;) { - if ( record_count && i == record->sequenceIndex ) + if (record_count && i == record->sequenceIndex) { unsigned int old_pos = buffer->in_pos; @@ -146,7 +146,7 @@ struct Rule { DEFINE_ARRAY_TYPE (USHORT, value, (glyphCount ? glyphCount - 1 : 0)); inline bool apply (LOOKUP_ARGS_DEF, ContextLookupContext &context) const { - const LookupRecord *record = (const LookupRecord *) ((const char *) value + sizeof (value[0]) * (glyphCount - 1)); + const LookupRecord *record = (const LookupRecord *) ((const char *) value + sizeof (value[0]) * (glyphCount ? glyphCount - 1 : 0)); return context_lookup (LOOKUP_ARGS, glyphCount, recordCount, diff --git a/src/hb-ot-layout-open-private.h b/src/hb-ot-layout-open-private.h index 68af73097..691f3924e 100644 --- a/src/hb-ot-layout-open-private.h +++ b/src/hb-ot-layout-open-private.h @@ -755,7 +755,7 @@ struct CoverageRangeRecord { USHORT startCoverageIndex; /* Coverage Index of first GlyphID in * range */ }; -ASSERT_SIZE_DATA (CoverageRangeRecord, 6, "\001"); +ASSERT_SIZE_DATA (CoverageRangeRecord, 6, "\000\001"); struct CoverageFormat2 { @@ -841,7 +841,7 @@ struct ClassRangeRecord { GlyphID end; /* Last GlyphID in the range */ USHORT classValue; /* Applied to all glyphs in the range */ }; -ASSERT_SIZE_DATA (ClassRangeRecord, 6, "\001"); +ASSERT_SIZE_DATA (ClassRangeRecord, 6, "\000\001"); struct ClassDefFormat2 {