From 3806ea8716699db7c29ded51f76a694f7bfde18b Mon Sep 17 00:00:00 2001 From: Ilkka Ollakka Date: Tue, 28 Jul 2009 16:04:49 +0300 Subject: [PATCH] freetype: add more error-checking should not crash if font family not found. Thanks to Anthony Loiseau for spotting this one. --- modules/misc/freetype.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/misc/freetype.c b/modules/misc/freetype.c index 0dc31431fe..f41630b71f 100644 --- a/modules/misc/freetype.c +++ b/modules/misc/freetype.c @@ -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 -- 2.39.2