]> git.wh0rd.org Git - fontconfig.git/commitdiff
Destroy the global cache file if it's terminally broken. (reported by Mike
authorPatrick Lam <plam@MIT.EDU>
Fri, 21 Oct 2005 20:24:30 +0000 (20:24 +0000)
committerPatrick Lam <plam@MIT.EDU>
Fri, 21 Oct 2005 20:24:30 +0000 (20:24 +0000)
    Fabian)

ChangeLog
src/fccache.c

index ed9e05b22039bfac21c5ebbfb46f1f866ca9536c..599e29879f2832bdfb93e3878c83378e7f3daeb1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,16 @@
+2005-10-21  Patrick Lam  <plam@mit.edu>
+       * src/fccache.c (FcGlobalCacheLoad):
+
+       Destroy the global cache file if it's terminally broken.  (reported by
+       Mike Fabian)
+
 2005-10-21  Patrick Lam  <plam@mit.edu>
        * fc-list/fc-list.c (main):
        * src/fcname.c (FcNameUnparse, FcNameUnparseEscaped):
        * fontconfig/fontconfig.h:
 
-       Prevent fc-list from escaping strings when printing them.
+       Prevent fc-list from escaping strings when printing them (reported by
+       Matthias Clasen).
 
 2005-10-20  Marcus Meissner  <meissner@suse.de>
        reviewed by: plam
index 0bbfffe244b2ad6cb9ccd4c247296ee6971d87c7..e761f36530e1e6d11276be2a54d0071d4811bb9b 100644 (file)
@@ -172,13 +172,13 @@ FcGlobalCacheLoad (FcGlobalCache    *cache,
     current_arch_start = FcCacheSkipToArch(cache->fd, 
                                           current_arch_machine_name);
     if (current_arch_start < 0)
-        goto bail0;
+        goto bail_and_destroy;
 
     lseek (cache->fd, current_arch_start, SEEK_SET);
     FcCacheReadString (cache->fd, candidate_arch_machine_name, 
                        sizeof (candidate_arch_machine_name));
     if (strlen(candidate_arch_machine_name) == 0)
-       goto bail0;
+       goto bail_and_destroy;
 
     while (1) 
     {
@@ -224,10 +224,20 @@ FcGlobalCacheLoad (FcGlobalCache    *cache,
        free (d);
     }
     cache->dirs = 0;
- bail0:
+
     close (cache->fd);
     cache->fd = -1;
     return;
+
+ bail_and_destroy:
+    close (cache->fd);
+    cache->fd = -1;
+
+    if (stat ((char *) cache_file, &cache_stat) == 0)
+        unlink ((char *)cache_file);
+
+    return;
+
 }
 
 FcBool