[Fontconfig] fontconfig: Branch 'master'

Akira TAGOH tagoh at kemper.freedesktop.org
Wed Mar 21 20:37:44 PDT 2012


 fc-cache/fc-cache.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

New commits:
commit 1db3e9cdd8bc7408e630934cfc8deda7798b8970
Author: Akira TAGOH <akira at tagoh.org>
Date:   Thu Mar 22 12:36:34 2012 +0900

    fc-cache: improvement of the fix for Bug#39914.
    
    Use sizeof() instead of strlen() and use stdio.

diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c
index 10bbea5..24bb2ec 100644
--- a/fc-cache/fc-cache.c
+++ b/fc-cache/fc-cache.c
@@ -131,18 +131,16 @@ create_tag_file (FcConfig *config, FcBool verbose)
     FcChar8		 *cache_dir = NULL;
     FcStrList		 *list;
     int 		 fd;
+    FILE                 *fp;
     FcAtomic	 	 *atomic;
     static const FcChar8 cache_tag_contents[] =
 	"Signature: 8a477f597d28d172789f06886806bc55\n"
 	"# This file is a cache directory tag created by fontconfig.\n"
 	"# For information about cache directory tags, see:\n"
 	"#       http://www.brynosaurus.com/cachedir/\n";
-    static size_t	 cache_tag_contents_size = 0;
+    static size_t	 cache_tag_contents_size = sizeof (cache_tag_contents) - 1;
     FcBool		 ret = FcTrue;
 
-    if (cache_tag_contents_size == 0)
-	cache_tag_contents_size = strlen((char *)cache_tag_contents);
-
     list = FcConfigGetCacheDirs(config);
     if (!list)
 	return FcFalse;
@@ -165,9 +163,12 @@ create_tag_file (FcConfig *config, FcBool verbose)
 	    fd = open((char *)FcAtomicNewFile (atomic), O_RDWR | O_CREAT, 0644);
 	    if (fd == -1)
 		goto bail3;
+	    fp = fdopen(fd, "wb");
+	    if (fp == NULL)
+		goto bail3;
 
-	    write(fd, cache_tag_contents, cache_tag_contents_size);
-	    close(fd);
+	    fwrite(cache_tag_contents, cache_tag_contents_size, sizeof (FcChar8), fp);
+	    fclose(fp);
 
 	    if (!FcAtomicReplaceOrig(atomic))
 		goto bail3;


More information about the Fontconfig mailing list