From aec04a301f2e181626f7a3067d69e003ba915b32 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 --- pango/opentype/hb-ot-layout-gsub-private.h | 7 +++++-- pango/opentype/hb-ot-layout-gsubgpos-private.h | 4 ++-- pango/opentype/hb-ot-layout-open-private.h | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pango/opentype/hb-ot-layout-gsub-private.h b/pango/opentype/hb-ot-layout-gsub-private.h index 74f4e36..89f4fd8 100644 --- a/pango/opentype/hb-ot-layout-gsub-private.h +++ b/pango/opentype/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/pango/opentype/hb-ot-layout-gsubgpos-private.h b/pango/opentype/hb-ot-layout-gsubgpos-private.h index b537015..033078b 100644 --- a/pango/opentype/hb-ot-layout-gsubgpos-private.h +++ b/pango/opentype/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/pango/opentype/hb-ot-layout-open-private.h b/pango/opentype/hb-ot-layout-open-private.h index 2c39a09..3c08130 100644 --- a/pango/opentype/hb-ot-layout-open-private.h +++ b/pango/opentype/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 { -- 2.7.4