]> granicus.if.org Git - libass/commitdiff
Fix fontconfig memory leaks
authorGrigori Goronzy <greg@blackbox>
Fri, 24 Jul 2009 08:01:41 +0000 (10:01 +0200)
committerGrigori Goronzy <greg@blackbox>
Fri, 24 Jul 2009 13:39:20 +0000 (15:39 +0200)
Do not manually use FcConfigFilename; passing a NULL pointer to
FcConfigParseAndLoad is just as effective and also avoids a memory leak
since the string allocated by FcConfigFilename was never freed.

Free FcConfig instance in fontconfig_done; since we're not using the
default configuration anymore it doesn't make sense to keep the
configuration around.

Leaks were found by valgrind/memcheck.

libass/ass_fontconfig.c

index bff8bed6619617cfac6b6061b6dcce412de82cc7..eb75c0badaac9e1d6f0cb6ee39f9ba3f55f749c5 100644 (file)
@@ -448,9 +448,6 @@ fc_instance_t *fontconfig_init(ass_library_t *library,
         goto exit;
     }
 
-    if (!config)
-        config = (char *) FcConfigFilename(NULL);
-
     priv->config = FcConfigCreate();
     rc = FcConfigParseAndLoad(priv->config, (unsigned char *) config, FcTrue);
     if (!rc) {
@@ -567,7 +564,8 @@ int fontconfig_update(fc_instance_t *priv)
 
 void fontconfig_done(fc_instance_t *priv)
 {
-    // don't call FcFini() here, library can still be used by some code
+    if (priv && priv->config)
+        FcConfigDestroy(priv->config);
     if (priv && priv->path_default)
         free(priv->path_default);
     if (priv && priv->family_default)