freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [base] Report used stream's external st


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] [base] Report used stream's external status.
Date: Thu, 05 Jan 2023 21:09:27 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

  • 15afb554
    by Ben Wagner at 2023-01-05T22:05:02+01:00
    [base] Report used stream's external status.
    
    In `open_face` the initial stream is set on the face, along with the
    information about if FreeType is the owner of the stream object itself.  The
    loaders may in the course of their work replace this stream with a new
    stream (as is the case for 'woff' and 'woff2'), which may have a different
    ownership than the initial stream object (likely the original stream object
    is owned by the user and is external, while the new stream object is created
    internally to FreeType and is internal).  When the stream is replaced, the
    face's flags are updated with the new ownership status.
    
    However, `open_face` cannot itself free this stream as its caller
    `ft_open_face_internal` is responsible for this.  In addition, in the case
    of an error `open_face` cannot return an actual face with the new stream and
    its ownership status to the caller.  As a result, it must pass this
    information back to the caller as a sort of "failed face" so that the caller
    can clean up.
    
    `open_face` was already passing back the new stream but was not passing back
    the stream ownership information.  As a result the stream may not have been
    free'd when needed.
    
    Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54700
    
    * src/base/ftobjs.c (open_face): Pass back the ownership information as
    well.
    (ft_open_face_internal): Updated.
    

1 changed file:

Changes:

  • src/base/ftobjs.c
    ... ... @@ -1489,7 +1489,7 @@
    1489 1489
       static FT_Error
    
    1490 1490
       open_face( FT_Driver      driver,
    
    1491 1491
                  FT_Stream      *astream,
    
    1492
    -             FT_Bool        external_stream,
    
    1492
    +             FT_Bool        *anexternal_stream,
    
    1493 1493
                  FT_Long        face_index,
    
    1494 1494
                  FT_Int         num_params,
    
    1495 1495
                  FT_Parameter*  params,
    
    ... ... @@ -1515,7 +1515,7 @@
    1515 1515
         face->stream = *astream;
    
    1516 1516
     
    
    1517 1517
         /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */
    
    1518
    -    if ( external_stream )
    
    1518
    +    if ( *anexternal_stream )
    
    1519 1519
           face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM;
    
    1520 1520
     
    
    1521 1521
         if ( FT_NEW( internal ) )
    
    ... ... @@ -1545,7 +1545,10 @@
    1545 1545
                                     (FT_Int)face_index,
    
    1546 1546
                                     num_params,
    
    1547 1547
                                     params );
    
    1548
    -    *astream = face->stream; /* Stream may have been changed. */
    
    1548
    +    /* Stream may have been changed. */
    
    1549
    +    *astream = face->stream;
    
    1550
    +    *anexternal_stream =
    
    1551
    +      ( face->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0;
    
    1549 1552
         if ( error )
    
    1550 1553
           goto Fail;
    
    1551 1554
     
    
    ... ... @@ -2586,7 +2589,7 @@
    2586 2589
               params     = args->params;
    
    2587 2590
             }
    
    2588 2591
     
    
    2589
    -        error = open_face( driver, &stream, external_stream, face_index,
    
    2592
    +        error = open_face( driver, &stream, &external_stream, face_index,
    
    2590 2593
                                num_params, params, &face );
    
    2591 2594
             if ( !error )
    
    2592 2595
               goto Success;
    
    ... ... @@ -2622,7 +2625,7 @@
    2622 2625
                 params     = args->params;
    
    2623 2626
               }
    
    2624 2627
     
    
    2625
    -          error = open_face( driver, &stream, external_stream, face_index,
    
    2628
    +          error = open_face( driver, &stream, &external_stream, face_index,
    
    2626 2629
                                  num_params, params, &face );
    
    2627 2630
               if ( !error )
    
    2628 2631
                 goto Success;
    


  • reply via email to

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