freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] Fix invalid memory access in `bsdf` ras


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] Fix invalid memory access in `bsdf` rasterizer.
Date: Mon, 02 Aug 2021 03:57:31 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

1 changed file:

Changes:

  • src/sdf/ftsdfrend.c
    ... ... @@ -298,8 +298,15 @@
    298 298
           goto Exit;
    
    299 299
         }
    
    300 300
     
    
    301
    +    /* the rows and pitch must be valid after presetting the */
    
    302
    +    /* bitmap using outline                                  */
    
    301 303
         if ( !bitmap->rows || !bitmap->pitch )
    
    304
    +    {
    
    305
    +      FT_ERROR(( "ft_sdf_render: failed to preset bitmap\n" ));
    
    306
    +
    
    307
    +      error = FT_THROW( Cannot_Render_Glyph );
    
    302 308
           goto Exit;
    
    309
    +    }
    
    303 310
     
    
    304 311
         /* the padding will simply be equal to the `spread' */
    
    305 312
         x_pad = sdf_module->spread;
    
    ... ... @@ -350,6 +357,10 @@
    350 357
         error = render->raster_render( render->raster,
    
    351 358
                                        (const FT_Raster_Params*)&params );
    
    352 359
     
    
    360
    +    /* transform the outline back to the original state */
    
    361
    +    if ( x_shift || y_shift )
    
    362
    +      FT_Outline_Translate( outline, -x_shift, -y_shift );
    
    363
    +
    
    353 364
       Exit:
    
    354 365
         if ( !error )
    
    355 366
         {
    
    ... ... @@ -362,9 +373,6 @@
    362 373
           slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
    
    363 374
         }
    
    364 375
     
    
    365
    -    if ( x_shift || y_shift )
    
    366
    -      FT_Outline_Translate( outline, -x_shift, -y_shift );
    
    367
    -
    
    368 376
         return error;
    
    369 377
       }
    
    370 378
     
    
    ... ... @@ -506,8 +514,24 @@
    506 514
           goto Exit;
    
    507 515
         }
    
    508 516
     
    
    517
    +    /* Do not generate SDF if the bitmap is not owned by the       */
    
    518
    +    /* glyph: it might be that the source buffer is already freed. */
    
    519
    +    if ( !( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) )
    
    520
    +    {
    
    521
    +      FT_ERROR(( "ft_bsdf_render: can't generate SDF from"
    
    522
    +                 " unowned source bitmap\n" ));
    
    523
    +
    
    524
    +      error = FT_THROW( Invalid_Argument );
    
    525
    +      goto Exit;
    
    526
    +    }
    
    527
    +
    
    509 528
         if ( !bitmap->rows || !bitmap->pitch )
    
    529
    +    {
    
    530
    +      FT_ERROR(( "ft_bsdf_render: invalid bitmap size\n" ));
    
    531
    +
    
    532
    +      error = FT_THROW( Invalid_Argument );
    
    510 533
           goto Exit;
    
    534
    +    }
    
    511 535
     
    
    512 536
         FT_Bitmap_New( &target );
    
    513 537
     
    


  • reply via email to

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