[vlc-commits] freetype: provide a proper fix to prevent ATS from crashing when searching for the font family instead of the fontname

Felix Paul Kühne git at videolan.org
Thu May 31 15:03:11 CEST 2012


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Thu May 31 14:54:12 2012 +0200| [10e87394ea679dd8bdabc582d4f83ca90f9e8c40] | committer: Felix Paul Kühne

freetype: provide a proper fix to prevent ATS from crashing when searching for the font family instead of the fontname

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

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

diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c
index a7c7afd..660d492 100644
--- a/modules/text_renderer/freetype.c
+++ b/modules/text_renderer/freetype.c
@@ -726,9 +726,8 @@ static char* MacLegacy_Select( filter_t *p_filter, const char* psz_fontname,
     cf_fontName = CFStringCreateWithCString( kCFAllocatorDefault, psz_fontname, kCFStringEncodingUTF8 );
 
     ats_font_id = ATSFontFindFromName( cf_fontName, kATSOptionFlagsIncludeDisabledMask );
-    CFRelease( cf_fontName );
 
-    if ( ats_font_id == 0xFFFFFFFFUL )
+    if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
     {
         msg_Dbg( p_filter, "ATS couldn't find %s by name, checking family", psz_fontname );
         ats_font_id = ATSFontFamilyFindFromName( cf_fontName, kATSOptionFlagsDefault );
@@ -736,14 +735,11 @@ static char* MacLegacy_Select( filter_t *p_filter, const char* psz_fontname,
         if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
         {
             msg_Err( p_filter, "ATS couldn't find either %s nor its family", psz_fontname );
+            CFRelease( cf_fontName );
             return NULL;
         }
     }
-    else if( ats_font_id == 0 )
-    {
-        msg_Err( p_filter, "ATS couldn't find %s by name, won't check family", psz_fontname );
-        return NULL;
-    }
+    CFRelease( cf_fontName );
 
     if ( noErr != ATSFontGetFileReference( ats_font_id, &ref ) )
     {



More information about the vlc-commits mailing list