diff options
author | Akira TAGOH <akira@tagoh.org> | 2014-08-12 18:48:00 +0900 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2014-08-12 18:48:00 +0900 |
commit | 23e88d8c6a5d3d0a9526a3f3217bd33a7607cbab (patch) | |
tree | f9309a19a77bd2a3fe71a2abb480b0c644972568 | |
parent | 841753a93f0e5698663b7931b8456e7b96259f54 (diff) | |
download | fontconfig-23e88d8c6a5d3d0a9526a3f3217bd33a7607cbab.tar.gz |
Increase the refcount in FcConfigSetCurrent()
https://bugs.freedesktop.org/show_bug.cgi?id=82432
-rw-r--r-- | fc-cat/fc-cat.c | 1 | ||||
-rw-r--r-- | src/fccfg.c | 5 | ||||
-rw-r--r-- | src/fcinit.c | 9 |
3 files changed, 14 insertions, 1 deletions
diff --git a/fc-cat/fc-cat.c b/fc-cat/fc-cat.c index 9a2abb3..3a303c2 100644 --- a/fc-cat/fc-cat.c +++ b/fc-cat/fc-cat.c @@ -298,6 +298,7 @@ main (int argc, char **argv) return 1; } FcConfigSetCurrent (config); + FcConfigDestroy (config); args = FcStrSetCreate (); if (!args) diff --git a/src/fccfg.c b/src/fccfg.c index f8ee8d2..55cb297 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -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); } } diff --git a/src/fcinit.c b/src/fcinit.c index 1e23c1f..db62c21 100644 --- a/src/fcinit.c +++ b/src/fcinit.c @@ -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 |