[vlc-commits] freetype: handle freeing bitmap glyphs

Francois Cartegnie git at videolan.org
Thu Sep 10 23:11:26 CEST 2020


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Jun 30 13:14:03 2020 +0200| [cb1b6dd989f03ade34b839d9178358abdff7d968] | committer: Francois Cartegnie

freetype: handle freeing bitmap glyphs

Currently double free is only prevented by
FT_Set_Pixel_Sizes error on pure bitmaps.

FT_LOAD_NO_BITMAP does not exclude bitmap only fonts
and FT_Glyph_To_Bitmap is no-op for bitmap fonts,
shadow glyph pointer can then end pointing to same
glyph as main glyph.

(cherry picked from commit d088e548b20d9d0c220ea973c71ffbc891551aac)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=cb1b6dd989f03ade34b839d9178358abdff7d968
---

 modules/text_renderer/freetype/text_layout.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/text_renderer/freetype/text_layout.c b/modules/text_renderer/freetype/text_layout.c
index 239a9fa988..f4e211b83a 100644
--- a/modules/text_renderer/freetype/text_layout.c
+++ b/modules/text_renderer/freetype/text_layout.c
@@ -172,7 +172,7 @@ static void FreeLine( line_desc_t *p_line )
         FT_Done_Glyph( (FT_Glyph)ch->p_glyph );
         if( ch->p_outline )
             FT_Done_Glyph( (FT_Glyph)ch->p_outline );
-        if( ch->p_shadow )
+        if( ch->p_shadow && ch->p_shadow != ch->p_glyph )
             FT_Done_Glyph( (FT_Glyph)ch->p_shadow );
     }
 
@@ -1187,7 +1187,7 @@ static int LayoutLine( filter_t *p_filter,
                 FT_Done_Glyph( p_bitmaps->p_glyph );
                 if( p_bitmaps->p_outline )
                     FT_Done_Glyph( p_bitmaps->p_outline );
-                if( p_bitmaps->p_shadow )
+                if( p_bitmaps->p_shadow != p_bitmaps->p_glyph )
                     FT_Done_Glyph( p_bitmaps->p_shadow );
                 --i_line_index;
                 continue;



More information about the vlc-commits mailing list