Increase the refcount in FcConfigSetCurrent()

https://bugs.freedesktop.org/show_bug.cgi?id=82432
This commit is contained in:
Akira TAGOH 2014-08-12 18:48:00 +09:00
parent 841753a93f
commit 23e88d8c6a
3 changed files with 14 additions and 1 deletions

View File

@ -298,6 +298,7 @@ main (int argc, char **argv)
return 1;
}
FcConfigSetCurrent (config);
FcConfigDestroy (config);
args = FcStrSetCreate ();
if (!args)

View File

@ -434,6 +434,7 @@ retry:
if (!fc_atomic_ptr_cmpexch (&_fcConfig, cfg, config))
goto retry;
FcConfigReference (config);
if (cfg)
FcConfigDestroy (cfg);
@ -2405,6 +2406,10 @@ FcConfigSetSysRoot (FcConfig *config,
{
config = FcInitLoadOwnConfigAndFonts (config);
FcConfigSetCurrent (config);
/* FcConfigSetCurrent() increases the refcount.
* decrease it here to avoid the memory leak.
*/
FcConfigDestroy (config);
}
}

View File

@ -189,11 +189,18 @@ FcBool
FcInitReinitialize (void)
{
FcConfig *config;
FcBool ret;
config = FcInitLoadConfigAndFonts ();
if (!config)
return FcFalse;
return FcConfigSetCurrent (config);
ret = FcConfigSetCurrent (config);
/* FcConfigSetCurrent() increases the refcount.
* decrease it here to avoid the memory leak.
*/
FcConfigDestroy (config);
return ret;
}
FcBool