freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [truetype/GX] Use more robust condition


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] [truetype/GX] Use more robust conditions.
Date: Thu, 01 Aug 2024 23:15:17 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

  • 7c75b8a7
    by Alexei Podtelezhnikov (Алексей Подтележников) at 2024-08-01T19:14:44-04:00
    [truetype/GX] Use more robust conditions.
    
    * src/truetype/ttgxvar.c (ft_var_readpacked{points,deltas}): Rewrite
    conditions to avoid undefined behavior.
    

1 changed file:

Changes:

  • src/truetype/ttgxvar.c
    ... ... @@ -187,7 +187,7 @@
    187 187
     
    
    188 188
           if ( runcnt & GX_PT_POINTS_ARE_WORDS )
    
    189 189
           {
    
    190
    -        if ( p + 2 * cnt > stream->limit )
    
    190
    +        if ( 2 * cnt > (FT_UInt)( stream->limit - p ) )
    
    191 191
               goto Fail;
    
    192 192
     
    
    193 193
             for ( j = 0; j < cnt; j++ )
    
    ... ... @@ -198,7 +198,7 @@
    198 198
           }
    
    199 199
           else
    
    200 200
           {
    
    201
    -        if ( p + cnt > stream->limit )
    
    201
    +        if ( cnt > (FT_UInt)( stream->limit - p ) )
    
    202 202
               goto Fail;
    
    203 203
     
    
    204 204
             for ( j = 0; j < cnt; j++ )
    
    ... ... @@ -274,9 +274,7 @@
    274 274
         while ( i < delta_cnt )
    
    275 275
         {
    
    276 276
           if ( p >= stream->limit )
    
    277
    -      {
    
    278 277
             goto Fail;
    
    279
    -      }
    
    280 278
     
    
    281 279
           runcnt = FT_NEXT_BYTE( p );
    
    282 280
           cnt    = runcnt & GX_DT_DELTA_RUN_COUNT_MASK;
    
    ... ... @@ -293,7 +291,7 @@
    293 291
           }
    
    294 292
           else if ( runcnt & GX_DT_DELTAS_ARE_WORDS )
    
    295 293
           {
    
    296
    -        if ( p + 2 * cnt > stream->limit )
    
    294
    +        if ( 2 * cnt > (FT_UInt)( stream->limit - p ) )
    
    297 295
               goto Fail;
    
    298 296
     
    
    299 297
             for ( j = 0; j < cnt; j++ )
    
    ... ... @@ -301,7 +299,7 @@
    301 299
           }
    
    302 300
           else
    
    303 301
           {
    
    304
    -        if ( p + cnt > stream->limit )
    
    302
    +        if ( cnt > (FT_UInt)( stream->limit - p ) )
    
    305 303
               goto Fail;
    
    306 304
     
    
    307 305
             for ( j = 0; j < cnt; j++ )
    


  • reply via email to

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