summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2009-07-24 10:01:41 +0200
committerGrigori Goronzy <greg@blackbox>2009-07-24 15:39:20 +0200
commit074399f7dcb4c94cc86d87250c05ba497fe26e45 (patch)
tree4e2108ad71c63bc5964c5eac100e8950707b18ae
parent417a5b32da0d3b345299190ba3198cfed6f98275 (diff)
downloadlibass-074399f7dcb4c94cc86d87250c05ba497fe26e45.tar.bz2
libass-074399f7dcb4c94cc86d87250c05ba497fe26e45.tar.xz
Fix fontconfig memory leaks
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.
-rw-r--r--libass/ass_fontconfig.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/libass/ass_fontconfig.c b/libass/ass_fontconfig.c
index bff8bed..eb75c0b 100644
--- a/libass/ass_fontconfig.c
+++ b/libass/ass_fontconfig.c
@@ -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)