[vlc-devel] [PATCH] freetype: Fix a possible buffer corruption

Thierry Reding thierry.reding at avionic-design.de
Tue Jul 24 16:31:13 CEST 2012


Memory associated with a FcPattern is freed when the pattern is
destroyed, so copying the font filename needs to be done before
the call to FcPatternDestroy.

Signed-off-by: Thierry Reding <thierry.reding at avionic-design.de>
---
 modules/text_renderer/freetype.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c
index 0448ed4..d2ec092 100644
--- a/modules/text_renderer/freetype.c
+++ b/modules/text_renderer/freetype.c
@@ -507,6 +507,7 @@ static char* FontConfig_Select( FcConfig* config, const char* family,
     FcPattern *pat, *p_pat;
     FcChar8* val_s;
     FcBool val_b;
+    char *ret;
 
     /* Create a pattern and fills it */
     pat = FcPatternCreate();
@@ -569,8 +570,9 @@ static char* FontConfig_Select( FcConfig* config, const char* family,
         return NULL;
     }
 
+    ret = strdup( (const char*)val_s );
     FcPatternDestroy( p_pat );
-    return strdup( (const char*)val_s );
+    return ret;
 }
 #endif
 
-- 
1.7.11.2




More information about the vlc-devel mailing list