[vlc-commits] freetype: fix crash

Erwan Tulou git at videolan.org
Wed Sep 14 18:16:01 CEST 2011


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Wed Sep 14 17:13:50 2011 +0200| [533090db4c9c616649b449b3ad6d5743b920da5a] | committer: Erwan Tulou

freetype: fix crash

shadow and outline must be reset to NULL if the freetype call fails,
so that the same memory is not deallocated twice later on.

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

 modules/text_renderer/freetype.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c
index bf32c82..aadb9c5 100644
--- a/modules/text_renderer/freetype.c
+++ b/modules/text_renderer/freetype.c
@@ -1759,15 +1759,22 @@ static int GetGlyph( filter_t *p_filter,
     if( p_filter->p_sys->p_stroker )
     {
         outline = glyph;
-        FT_Glyph_StrokeBorder( &outline, p_filter->p_sys->p_stroker, 0, 0 );
+        if( FT_Glyph_StrokeBorder( &outline, p_filter->p_sys->p_stroker, 0, 0 ) )
+            outline = NULL;
     }
 
     FT_Glyph shadow = NULL;
     if( p_filter->p_sys->i_shadow_opacity > 0 )
     {
         shadow = outline ? outline : glyph;
-        FT_Glyph_To_Bitmap( &shadow, FT_RENDER_MODE_NORMAL, p_pen_shadow, 0 );
-        FT_Glyph_Get_CBox( shadow, ft_glyph_bbox_pixels, p_shadow_bbox );
+        if( FT_Glyph_To_Bitmap( &shadow, FT_RENDER_MODE_NORMAL, p_pen_shadow, 0  ) )
+        {
+            shadow = NULL;
+        }
+        else
+        {
+            FT_Glyph_Get_CBox( shadow, ft_glyph_bbox_pixels, p_shadow_bbox );
+        }
     }
     *pp_shadow = shadow;
 



More information about the vlc-commits mailing list