]> git.sesse.net Git - vlc/commitdiff
freetype: add more error-checking
authorIlkka Ollakka <ileoo@videolan.org>
Tue, 28 Jul 2009 13:04:49 +0000 (16:04 +0300)
committerIlkka Ollakka <ileoo@videolan.org>
Tue, 28 Jul 2009 13:06:07 +0000 (16:06 +0300)
should not crash if font family not found. Thanks to Anthony Loiseau for
spotting this one.

modules/misc/freetype.c

index 0dc31431fe85356fd6725d2d54069ab2139d099a..f41630b71f379d442320694aaead8d4fa128f90e 100644 (file)
@@ -361,13 +361,24 @@ static int Create( vlc_object_t *p_this )
     FcDefaultSubstitute( fontpattern );
 
     fontmatch = FcFontMatch( NULL, fontpattern, &fontresult );
+    if( fontmatch == FcResultNoMath )
+    {
+        free( psz_fontsize );
+        FcPatternDestroy( fontpattern );
+        FcPatternDestroy( fontmatch );
+        goto error;
+    }
 
     FcPatternGetString( fontmatch, FC_FILE, 0, (FcChar8 **)&psz_fontfile);
     FcPatternGetInteger( fontmatch, FC_INDEX, 0, &fontindex );
+    free( psz_fontsize );
     if( !psz_fontfile )
+    {
+        FcPatternDestroy( fontpattern );
+        FcPatternDestroy( fontmatch );
         goto error;
+    }
     msg_Dbg( p_filter, "Using %s as font from file %s", psz_fontfamily, psz_fontfile);
-    free( psz_fontsize );
 #else
     psz_fontfile = psz_fontfamily;
 #endif