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; return 1;
} }
FcConfigSetCurrent (config); FcConfigSetCurrent (config);
FcConfigDestroy (config);
args = FcStrSetCreate (); args = FcStrSetCreate ();
if (!args) if (!args)

View File

@ -434,6 +434,7 @@ retry:
if (!fc_atomic_ptr_cmpexch (&_fcConfig, cfg, config)) if (!fc_atomic_ptr_cmpexch (&_fcConfig, cfg, config))
goto retry; goto retry;
FcConfigReference (config);
if (cfg) if (cfg)
FcConfigDestroy (cfg); FcConfigDestroy (cfg);
@ -2405,6 +2406,10 @@ FcConfigSetSysRoot (FcConfig *config,
{ {
config = FcInitLoadOwnConfigAndFonts (config); config = FcInitLoadOwnConfigAndFonts (config);
FcConfigSetCurrent (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) FcInitReinitialize (void)
{ {
FcConfig *config; FcConfig *config;
FcBool ret;
config = FcInitLoadConfigAndFonts (); config = FcInitLoadConfigAndFonts ();
if (!config) if (!config)
return FcFalse; 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 FcBool