]> git.sesse.net Git - vlc/commitdiff
freetype: fix crash
authorErwan Tulou <erwan10@videolan.org>
Wed, 14 Sep 2011 15:13:50 +0000 (17:13 +0200)
committerErwan Tulou <erwan10@videolan.org>
Wed, 14 Sep 2011 16:10:50 +0000 (18:10 +0200)
shadow and outline must be reset to NULL if the freetype call fails,
so that the same memory is not deallocated twice later on.

modules/text_renderer/freetype.c

index bf32c825b720d5f061d2969c0dfc1774ef0978f5..aadb9c58fd9d40648dc6e3b700d9f5ecb1450606 100644 (file)
@@ -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;