Commit fbc05949 authored by Akira TAGOH's avatar Akira TAGOH

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 #227
parent 61573ad5
Pipeline #112670 passed with stage
in 5 minutes and 41 seconds
...@@ -365,7 +365,6 @@ FcDirCacheProcess (FcConfig *config, const FcChar8 *dir, ...@@ -365,7 +365,6 @@ FcDirCacheProcess (FcConfig *config, const FcChar8 *dir,
struct stat file_stat, dir_stat; struct stat file_stat, dir_stat;
FcBool ret = FcFalse; FcBool ret = FcFalse;
const FcChar8 *sysroot = FcConfigGetSysRoot (config); const FcChar8 *sysroot = FcConfigGetSysRoot (config);
struct timeval latest_mtime = (struct timeval){ 0 };
if (sysroot) if (sysroot)
d = FcStrBuildFilename (sysroot, dir, NULL); d = FcStrBuildFilename (sysroot, dir, NULL);
...@@ -390,6 +389,8 @@ FcDirCacheProcess (FcConfig *config, const FcChar8 *dir, ...@@ -390,6 +389,8 @@ FcDirCacheProcess (FcConfig *config, const FcChar8 *dir,
#ifndef _WIN32 #ifndef _WIN32
FcBool retried = FcFalse; FcBool retried = FcFalse;
#endif #endif
struct timeval latest_mtime = (struct timeval){ 0 };
if (sysroot) if (sysroot)
cache_hashed = FcStrBuildFilename (sysroot, cache_dir, cache_base, NULL); cache_hashed = FcStrBuildFilename (sysroot, cache_dir, cache_base, NULL);
else else
...@@ -1081,12 +1082,12 @@ FcDirCacheLoadFile (const FcChar8 *cache_file, struct stat *file_stat) ...@@ -1081,12 +1082,12 @@ FcDirCacheLoadFile (const FcChar8 *cache_file, struct stat *file_stat)
if (!file_stat) if (!file_stat)
file_stat = &my_file_stat; file_stat = &my_file_stat;
fd = FcDirCacheOpenFile (cache_file, file_stat);
if (fd < 0)
return NULL;
config = FcConfigReference (NULL); config = FcConfigReference (NULL);
if (!config) if (!config)
return NULL; return NULL;
fd = FcDirCacheOpenFile (cache_file, file_stat);
if (fd < 0)
return NULL;
cache = FcDirCacheMapFd (config, fd, file_stat, NULL); cache = FcDirCacheMapFd (config, fd, file_stat, NULL);
FcConfigDestroy (config); FcConfigDestroy (config);
close (fd); close (fd);
......
...@@ -199,10 +199,10 @@ void ...@@ -199,10 +199,10 @@ void
FcFini (void) FcFini (void)
{ {
FcConfigFini (); FcConfigFini ();
FcCacheFini (); FcConfigPathFini ();
FcDefaultFini (); FcDefaultFini ();
FcObjectFini (); FcObjectFini ();
FcConfigPathFini (); FcCacheFini ();
} }
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment