freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [base] Improve error handling in `FT_Gl


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] [base] Improve error handling in `FT_GlyphLoader_CheckPoints`.
Date: Sun, 03 Jul 2022 05:03:53 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

  • 1a242558
    by Chris Liddell at 2022-07-03T06:58:23+02:00
    [base] Improve error handling in `FT_GlyphLoader_CheckPoints`.
    
    If `FT_GlyphLoader_CreateExtra` returns an error (and a couple of other
    places), `FT_GlyphLoader_CheckPoints` would propagate the error immediately,
    rather than cleaning up the partially set up `FT_GlyphLoader`.  As a
    consequence, a subsequent attempt to create a glyph could result in a crash.
    
    * src/base/ftgloadr.c (FT_GlyphLoader_CheckPoints): Ensure all the error
    conditions exits are consistent, eventually calling `FT_GlyphLoader_Reset`.
    

1 changed file:

Changes:

  • src/base/ftgloadr.c
    ... ... @@ -217,7 +217,7 @@
    217 217
     
    
    218 218
         error = FT_GlyphLoader_CreateExtra( loader );
    
    219 219
         if ( error )
    
    220
    -      return error;
    
    220
    +      goto Exit;
    
    221 221
     
    
    222 222
         /* check points & tags */
    
    223 223
         new_max = (FT_UInt)base->n_points + (FT_UInt)current->n_points +
    
    ... ... @@ -229,7 +229,10 @@
    229 229
           new_max = FT_PAD_CEIL( new_max, 8 );
    
    230 230
     
    
    231 231
           if ( new_max > FT_OUTLINE_POINTS_MAX )
    
    232
    -        return FT_THROW( Array_Too_Large );
    
    232
    +      {
    
    233
    +        error = FT_THROW( Array_Too_Large );
    
    234
    +        goto Exit;
    
    235
    +      }
    
    233 236
     
    
    234 237
           if ( FT_RENEW_ARRAY( base->points, old_max, new_max ) ||
    
    235 238
                FT_RENEW_ARRAY( base->tags,   old_max, new_max ) )
    
    ... ... @@ -254,7 +257,7 @@
    254 257
     
    
    255 258
         error = FT_GlyphLoader_CreateExtra( loader );
    
    256 259
         if ( error )
    
    257
    -      return error;
    
    260
    +      goto Exit;
    
    258 261
     
    
    259 262
         /* check contours */
    
    260 263
         old_max = loader->max_contours;
    
    ... ... @@ -265,7 +268,10 @@
    265 268
           new_max = FT_PAD_CEIL( new_max, 4 );
    
    266 269
     
    
    267 270
           if ( new_max > FT_OUTLINE_CONTOURS_MAX )
    
    268
    -        return FT_THROW( Array_Too_Large );
    
    271
    +      {
    
    272
    +        error = FT_THROW( Array_Too_Large );
    
    273
    +        goto Exit;
    
    274
    +      }
    
    269 275
     
    
    270 276
           if ( FT_RENEW_ARRAY( base->contours, old_max, new_max ) )
    
    271 277
             goto Exit;
    


  • reply via email to

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