[Fontconfig] fontconfig: Branch 'main'

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 25 07:05:12 UTC 2021


 src/fccache.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

New commits:
commit 57032f489b2cbe98c8e7927f4c18738869831f41
Author: Akira TAGOH <akira at tagoh.org>
Date:   Wed Aug 25 15:52:53 2021 +0900

    Fix a memory leak when trying to open a non-existing file
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1914716

diff --git a/src/fccache.c b/src/fccache.c
index ae3b9e3..d8ffe09 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -1111,7 +1111,7 @@ FcCache *
 FcDirCacheLoadFile (const FcChar8 *cache_file, struct stat *file_stat)
 {
     int	fd;
-    FcCache *cache;
+    FcCache *cache = NULL;
     struct stat	my_file_stat;
     FcConfig *config;
 
@@ -1121,11 +1121,13 @@ FcDirCacheLoadFile (const FcChar8 *cache_file, struct stat *file_stat)
     if (!config)
 	return NULL;
     fd = FcDirCacheOpenFile (cache_file, file_stat);
-    if (fd < 0)
-	return NULL;
-    cache = FcDirCacheMapFd (config, fd, file_stat, NULL);
+    if (fd >= 0)
+    {
+	cache = FcDirCacheMapFd (config, fd, file_stat, NULL);
+	close (fd);
+    }
     FcConfigDestroy (config);
-    close (fd);
+
     return cache;
 }
 


More information about the Fontconfig mailing list