[HB] Couple size checks
authorBehdad Esfahbod <behdad@behdad.org>
Sun, 17 May 2009 13:45:32 +0000 (09:45 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Mon, 2 Nov 2009 19:40:10 +0000 (14:40 -0500)
src/hb-ot-layout-gsub-private.h
src/hb-ot-layout-gsubgpos-private.h
src/hb-ot-layout-open-private.h

index 74f4e36..89f4fd8 100644 (file)
@@ -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 */
index b537015..033078b 100644 (file)
@@ -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,
index 68af730..691f392 100644 (file)
@@ -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 {