freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [cff] Fix leak of cmap data


From: Ben Wagner (@bungeman)
Subject: [Git][freetype/freetype][master] [cff] Fix leak of cmap data
Date: Thu, 05 Dec 2024 15:01:41 +0000

Ben Wagner pushed to branch master at FreeType / FreeType

Commits:

  • 59320b2d
    by Ben Wagner at 2024-12-04T16:55:10-05:00
    [cff] Fix leak of cmap data
    
    When `sfnt->load_face` succeeds it has already loaded any (optional)
    cmap data. As a result, a subsequent call to `sfnt->load_cmap` will
    overwrite the cmap data pointer with a new copy of the data but not free
    the old, leading to a leak.
    
    This is a fix for "* src/cff/cffobjs.c (cff_face_init): Better handling
    of Type0 fonts.". This still allows the cmap to be missing but avoids
    the leak by only calling `sfnt->load_cmap` when there is no `head`
    table (the font data is not being loaded as OpenType/CFF).
    
    * src/cff/cffobjs.c (cff_face_init): Fix leak
    
    Fixes: #1306
    

1 changed file:

Changes:

  • src/cff/cffobjs.c
    ... ... @@ -537,8 +537,8 @@
    537 537
     
    
    538 538
           sfnt_format = 1;
    
    539 539
     
    
    540
    -      /* now, the font can be either an OpenType/CFF font, or an SVG CEF */
    
    541
    -      /* font; in the latter case it doesn't have a `head' table         */
    
    540
    +      /* the font may be OpenType/CFF, SVG CEF, or sfnt/CFF; a `head' table */
    
    541
    +      /* implies OpenType/CFF, otherwise just look for an optional cmap     */
    
    542 542
           error = face->goto_table( face, TTAG_head, stream, 0 );
    
    543 543
           if ( !error )
    
    544 544
           {
    
    ... ... @@ -550,13 +550,15 @@
    550 550
             if ( error )
    
    551 551
               goto Exit;
    
    552 552
           }
    
    553
    +      else
    
    554
    +      {
    
    555
    +        /* load the `cmap' table explicitly */
    
    556
    +        error = sfnt->load_cmap( face, stream );
    
    553 557
     
    
    554
    -      /* load the `cmap' table explicitly */
    
    555
    -      error = sfnt->load_cmap( face, stream );
    
    556
    -
    
    557
    -      /* this may fail because CID-keyed fonts don't have a cmap */
    
    558
    -      if ( FT_ERR_NEQ( error, Table_Missing ) && FT_ERR_NEQ( error, Ok ) )
    
    559
    -        goto Exit;
    
    558
    +        /* this may fail because CID-keyed fonts don't have a cmap */
    
    559
    +        if ( FT_ERR_NEQ( error, Table_Missing ) && FT_ERR_NEQ( error, Ok ) )
    
    560
    +          goto Exit;
    
    561
    +      }
    
    560 562
     
    
    561 563
           /* now load the CFF part of the file; */
    
    562 564
           /* give priority to CFF2              */
    


  • reply via email to

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