]> git.wh0rd.org - fontconfig.git/commitdiff
Ensure that a directory cache has the appropriate section before reporting
authorPatrick Lam <plam@MIT.EDU>
Mon, 3 Oct 2005 19:51:11 +0000 (19:51 +0000)
committerPatrick Lam <plam@MIT.EDU>
Mon, 3 Oct 2005 19:51:11 +0000 (19:51 +0000)
    that it is valid (reported by Matthias Clasen).

ChangeLog
src/fccache.c

index 318d26a4ee15c35740e9886ee09ee25fb48081bc..d85f2b28e1fbbc9ae32826cfd149e9ce188d10db 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-10-03  Patrick Lam  <plam@mit.edu>
+       * src/fccache.c (FcDirCacheValid):
+
+       Ensure that a directory cache has the appropriate section
+       before reporting that it is valid (reported by Matthias Clasen).
+
 2005-09-29  Mathias Hasselmann  <mathias.hasselmann@gmx.de>
 
         reviewed by: plam
index d001e2b255bec1d13a94d7336dc7ad7cd9d3f6bc..7ff9fc617e95da09cf0888df2840cf22f2115543 100644 (file)
@@ -522,6 +522,9 @@ FcDirCacheValid (const FcChar8 *dir)
 {
     FcChar8     *cache_file = FcStrPlus (dir, (FcChar8 *) "/" FC_DIR_CACHE_FILE);
     struct stat file_stat, dir_stat;
+    int        fd;
+    off_t      current_arch_start;
+    char       *current_arch_machine_name;
 
     if (stat ((char *) dir, &dir_stat) < 0)
     {
@@ -533,6 +536,18 @@ FcDirCacheValid (const FcChar8 *dir)
         FcStrFree (cache_file);
         return FcFalse;
     }
+
+    current_arch_machine_name = FcCacheMachineSignature();
+    fd = open(cache_file, O_RDONLY);
+    if (fd == -1)
+        return FcFalse;
+
+    current_arch_start = FcCacheSkipToArch(fd, current_arch_machine_name);
+    close (fd);
+
+    if (current_arch_start < 0)
+        return FcFalse;
+
     FcStrFree (cache_file);
     /*
      * If the directory has been modified more recently than