[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:12:29 CEST 2012


vlc/vlc-2.0 | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Thu May 31 14:54:12 2012 +0200| [dee1ee38cf21057cfddb06be95c21d9917b57894] | 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
(cherry picked from commit 10e87394ea679dd8bdabc582d4f83ca90f9e8c40)

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

 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 f24aa28..b6170aa 100644
--- a/modules/text_renderer/freetype.c
+++ b/modules/text_renderer/freetype.c
@@ -725,9 +725,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 );
@@ -735,14 +734,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