summaryrefslogtreecommitdiff
path: root/src/fccache.c
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2020-02-26 15:42:21 +0900
committerAkira TAGOH <akira@tagoh.org>2020-02-26 15:42:21 +0900
commitfbc05949ef52c8a8d69233eed77f6636dffec280 (patch)
tree5d188e9fc4d9ceade82add81fce8bee6d4f79a4e /src/fccache.c
parent61573ad5f7c4dd0860d613d99d0086433240eb75 (diff)
downloadfontconfig-fbc05949ef52c8a8d69233eed77f6636dffec280.tar.gz
Fix assertion in FcFini()
Due to the unproper initialization of `latest_mtime', the duplicate caches was still in fcCacheChains with no references. which means no one frees them. thus, the memory leak was happened. Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/227
Diffstat (limited to 'src/fccache.c')
-rw-r--r--src/fccache.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/fccache.c b/src/fccache.c
index 4744a84..035458e 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -365,7 +365,6 @@ FcDirCacheProcess (FcConfig *config, const FcChar8 *dir,
struct stat file_stat, dir_stat;
FcBool ret = FcFalse;
const FcChar8 *sysroot = FcConfigGetSysRoot (config);
- struct timeval latest_mtime = (struct timeval){ 0 };
if (sysroot)
d = FcStrBuildFilename (sysroot, dir, NULL);
@@ -390,6 +389,8 @@ FcDirCacheProcess (FcConfig *config, const FcChar8 *dir,
#ifndef _WIN32
FcBool retried = FcFalse;
#endif
+ struct timeval latest_mtime = (struct timeval){ 0 };
+
if (sysroot)
cache_hashed = FcStrBuildFilename (sysroot, cache_dir, cache_base, NULL);
else
@@ -1081,12 +1082,12 @@ FcDirCacheLoadFile (const FcChar8 *cache_file, struct stat *file_stat)
if (!file_stat)
file_stat = &my_file_stat;
- fd = FcDirCacheOpenFile (cache_file, file_stat);
- if (fd < 0)
- return NULL;
config = FcConfigReference (NULL);
if (!config)
return NULL;
+ fd = FcDirCacheOpenFile (cache_file, file_stat);
+ if (fd < 0)
+ return NULL;
cache = FcDirCacheMapFd (config, fd, file_stat, NULL);
FcConfigDestroy (config);
close (fd);