freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [smooth] Fortify 64-bit algorithm.


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] [smooth] Fortify 64-bit algorithm.
Date: Fri, 20 Aug 2021 17:58:12 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

1 changed file:

Changes:

  • src/smooth/ftgrays.c
    ... ... @@ -375,12 +375,12 @@ typedef ptrdiff_t FT_PtrDist;
    375 375
     
    
    376 376
       /* These macros speed up repetitive divisions by replacing them */
    
    377 377
       /* with multiplications and right shifts.                       */
    
    378
    -#define FT_UDIVPREP( c, b )                                        \
    
    379
    -  long  b ## _r = c ? (long)( FT_ULONG_MAX >> PIXEL_BITS ) / ( b ) \
    
    378
    +#define FT_UDIVPREP( c, b )                                                 \
    
    379
    +  FT_Int64  b ## _r = c ? (FT_Int64)( ~(FT_UInt64)0 >> PIXEL_BITS ) / ( b ) \
    
    380 380
                         : 0
    
    381
    -#define FT_UDIV( a, b )                                                \
    
    382
    -  (TCoord)( ( (unsigned long)( a ) * (unsigned long)( b ## _r ) ) >>   \
    
    383
    -            ( sizeof( long ) * FT_CHAR_BIT - PIXEL_BITS ) )
    
    381
    +#define FT_UDIV( a, b )                                         \
    
    382
    +  (TCoord)( ( (FT_UInt64)( a ) * (FT_UInt64)( b ## _r ) ) >>    \
    
    383
    +            ( sizeof( FT_UInt64 ) * FT_CHAR_BIT - PIXEL_BITS ) )
    
    384 384
     
    
    385 385
     
    
    386 386
       /* Scale area and apply fill rule to calculate the coverage byte. */
    
    ... ... @@ -921,7 +921,7 @@ typedef ptrdiff_t FT_PtrDist;
    921 921
         }
    
    922 922
         else                                  /* any other line */
    
    923 923
         {
    
    924
    -      TPos  prod = dx * (TPos)fy1 - dy * (TPos)fx1;
    
    924
    +      FT_Int64  prod = dx * (FT_Int64)fy1 - dy * (FT_Int64)fx1;
    
    925 925
           FT_UDIVPREP( ex1 != ex2, dx );
    
    926 926
           FT_UDIVPREP( ey1 != ey2, dy );
    
    927 927
     
    


  • reply via email to

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