[vlc-devel] commit: fontconfig: factorize and fix memleaks. ( Rémi Duraffort )
git version control
git at videolan.org
Thu Jul 30 14:34:05 CEST 2009
vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Thu Jul 30 14:33:40 2009 +0200| [6f2d1380b300486ac17b8155a88fb0ccef822728] | committer: Rémi Duraffort
fontconfig: factorize and fix memleaks.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6f2d1380b300486ac17b8155a88fb0ccef822728
---
modules/misc/freetype.c | 20 +++++++-------------
1 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/modules/misc/freetype.c b/modules/misc/freetype.c
index 0171d48..82eaa0e 100644
--- a/modules/misc/freetype.c
+++ b/modules/misc/freetype.c
@@ -297,7 +297,7 @@ static int Create( vlc_object_t *p_this )
int i_error,fontindex;
#ifdef HAVE_FONTCONFIG
- FcPattern *fontpattern, *fontmatch;
+ FcPattern *fontpattern = NULL, *fontmatch = NULL;
FcResult fontresult = FcResultNoMatch;
#endif
@@ -359,28 +359,18 @@ static int Create( vlc_object_t *p_this )
free( psz_fontsize );
if( FcConfigSubstitute( NULL, fontpattern, FcMatchPattern ) == FcFalse )
- {
- FcPatternDestroy( fontpattern );
goto error;
- }
FcDefaultSubstitute( fontpattern );
fontmatch = FcFontMatch( NULL, fontpattern, &fontresult );
if( !fontmatch || fontresult == FcResultNoMatch )
- {
- FcPatternDestroy( fontpattern );
goto error;
- }
FcPatternGetString( fontmatch, FC_FILE, 0, (FcChar8 **)&psz_fontfile);
FcPatternGetInteger( fontmatch, FC_INDEX, 0, &fontindex );
if( !psz_fontfile )
- {
- FcPatternDestroy( fontpattern );
- FcPatternDestroy( fontmatch );
goto error;
- }
- msg_Dbg( p_filter, "Using %s as font from file %s", psz_fontfamily, psz_fontfile);
+ msg_Dbg( p_filter, "Using %s as font from file %s", psz_fontfamily, psz_fontfile );
#else
psz_fontfile = psz_fontfamily;
#endif
@@ -441,7 +431,11 @@ static int Create( vlc_object_t *p_this )
return VLC_SUCCESS;
- error:
+error:
+#ifdef HAVE_FONTCONFIG
+ if( fontmatch ) FcPatternDestroy( fontmatch );
+ if( fontpattern ) FcPatternDestroy( fontpattern );
+#endif
if( p_sys->p_face ) FT_Done_Face( p_sys->p_face );
if( p_sys->p_library ) FT_Done_FreeType( p_sys->p_library );
free( psz_fontfile );
More information about the vlc-devel
mailing list