freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][master] 2 commits: [ftgrid] Fix memory-re


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype-demos][master] 2 commits: [ftgrid] Fix memory-related problems.
Date: Fri, 29 Jul 2022 22:34:25 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType Demo Programs

Commits:

  • 794730a0
    by Werner Lemberg at 2022-07-30T00:04:46+02:00
    [ftgrid] Fix memory-related problems.
    
    Reported by Marc Schönefeld <marc.schoenefeld@gmx.org>.
    
    * src/ftgrid.c (bitmap_scale): Limit bitmap size.
    (grid_status_draw_outline): Handle errors in `FT_Get_Glyph`.
    
  • d2dcacab
    by Werner Lemberg at 2022-07-30T00:26:17+02:00
    * src/ftlint.c (main): Check number of glyphs.
    
    Problem reported by Marc Schönefeld <marc.schoenefeld@gmx.org>..
    

2 changed files:

Changes:

  • src/ftgrid.c
    ... ... @@ -408,8 +408,12 @@
    408 408
                                : -bit->pitch;
    
    409 409
         width = bit->width;
    
    410 410
     
    
    411
    -    line = (unsigned char*)malloc( (size_t)( pitch * bit->rows *
    
    412
    -                                             scale * scale ) );
    
    411
    +    /* limit bitmap size */
    
    412
    +    if ( pitch * scale <= 0xFFFF && bit->rows * scale <= 0xFFFF )
    
    413
    +      line = (unsigned char*)malloc( (size_t)( pitch * bit->rows *
    
    414
    +                                               scale * scale ) );
    
    415
    +    else
    
    416
    +      line = NULL;
    
    413 417
     
    
    414 418
         bit->buffer = line;  /* the bitmap now owns this buffer */
    
    415 419
     
    
    ... ... @@ -585,10 +589,12 @@
    585 589
           grBitmap  bitg;
    
    586 590
     
    
    587 591
     
    
    588
    -      FT_Get_Glyph( slot, &glyph );
    
    589
    -      error  = FTDemo_Glyph_To_Bitmap( handle, glyph, &bitg, &left, &top,
    
    590
    -                                       &x_advance, &y_advance, &glyf);
    
    592
    +      err = FT_Get_Glyph( slot, &glyph );
    
    593
    +      if ( err )
    
    594
    +        return;
    
    591 595
     
    
    596
    +      error = FTDemo_Glyph_To_Bitmap( handle, glyph, &bitg, &left, &top,
    
    597
    +                                      &x_advance, &y_advance, &glyf);
    
    592 598
           if ( !error )
    
    593 599
           {
    
    594 600
             bitmap_scale( st, &bitg, scale );
    
    ... ... @@ -633,7 +639,10 @@
    633 639
           /* stroke then draw it */
    
    634 640
           if ( st->work & DO_OUTLINE )
    
    635 641
           {
    
    636
    -        FT_Get_Glyph( slot, &glyph );
    
    642
    +        err = FT_Get_Glyph( slot, &glyph );
    
    643
    +        if ( err )
    
    644
    +          return;
    
    645
    +
    
    637 646
             FT_Glyph_Stroke( &glyph, st->stroker, 1 );
    
    638 647
     
    
    639 648
             error = FTDemo_Sketch_Glyph_Color( handle, display, glyph,
    

  • src/ftlint.c
    ... ... @@ -262,6 +262,10 @@
    262 262
             goto Finalize;
    
    263 263
           }
    
    264 264
     
    
    265
    +      /* nothing to do */
    
    266
    +      if ( !face->num_glyphs )
    
    267
    +        goto Finalize;
    
    268
    +
    
    265 269
           fi = first_index > 0 ? first_index : 0;
    
    266 270
           li = last_index < (unsigned int)face->num_glyphs ?
    
    267 271
                             last_index : (unsigned int)face->num_glyphs - 1;
    


  • reply via email to

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