freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype][master] * src/otvalid/otvgsub.c (otv_SingleSubs


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] * src/otvalid/otvgsub.c (otv_SingleSubst_validate): Fix format 1 handling.
Date: Thu, 15 Sep 2022 07:18:31 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

  • a0d15364
    by Werner Lemberg at 2022-09-15T09:14:06+02:00
    * src/otvalid/otvgsub.c (otv_SingleSubst_validate): Fix format 1 handling.
    
    Fixes #1181.
    

1 changed file:

Changes:

  • src/otvalid/otvgsub.c
    ... ... @@ -61,7 +61,8 @@
    61 61
           {
    
    62 62
             FT_Bytes  Coverage;
    
    63 63
             FT_Int    DeltaGlyphID;
    
    64
    -        FT_Long   idx;
    
    64
    +        FT_UInt   first_cov, last_cov;
    
    65
    +        FT_UInt   first_idx, last_idx;
    
    65 66
     
    
    66 67
     
    
    67 68
             OTV_LIMIT_CHECK( 4 );
    
    ... ... @@ -70,12 +71,21 @@
    70 71
     
    
    71 72
             otv_Coverage_validate( Coverage, otvalid, -1 );
    
    72 73
     
    
    73
    -        idx = (FT_Long)otv_Coverage_get_first( Coverage ) + DeltaGlyphID;
    
    74
    -        if ( idx < 0 )
    
    74
    +        first_cov = otv_Coverage_get_first( Coverage );
    
    75
    +        last_cov  = otv_Coverage_get_last( Coverage );
    
    76
    +
    
    77
    +        /* These additions are modulo 65536. */
    
    78
    +        first_idx = (FT_UInt)( (FT_Int)first_cov + DeltaGlyphID ) & 0xFFFFU;
    
    79
    +        last_idx  = (FT_UInt)( (FT_Int)last_cov + DeltaGlyphID ) & 0xFFFFU;
    
    80
    +
    
    81
    +        /* Since the maximum number of glyphs is 2^16 - 1 = 65535, */
    
    82
    +        /* the largest possible glyph index is 65534.  For this    */
    
    83
    +        /* reason there can't be a wrap-around region, which would */
    
    84
    +        /* imply the use of the invalid glyph index 65535.         */
    
    85
    +        if ( first_idx > last_idx )
    
    75 86
               FT_INVALID_DATA;
    
    76 87
     
    
    77
    -        idx = (FT_Long)otv_Coverage_get_last( Coverage ) + DeltaGlyphID;
    
    78
    -        if ( (FT_UInt)idx >= otvalid->glyph_count )
    
    88
    +        if ( last_idx >= otvalid->glyph_count )
    
    79 89
               FT_INVALID_DATA;
    
    80 90
           }
    
    81 91
           break;
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]