From: Patrick Lam Date: Fri, 21 Oct 2005 20:24:30 +0000 (+0000) Subject: Destroy the global cache file if it's terminally broken. (reported by Mike X-Git-Tag: fc-2_3_92~18 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=e58b50e88cbe3b55695101a0988306ea4646bbe4;p=fontconfig.git Destroy the global cache file if it's terminally broken. (reported by Mike Fabian) --- diff --git a/ChangeLog b/ChangeLog index ed9e05b..599e298 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,16 @@ +2005-10-21 Patrick Lam + * src/fccache.c (FcGlobalCacheLoad): + + Destroy the global cache file if it's terminally broken. (reported by + Mike Fabian) + 2005-10-21 Patrick Lam * 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 reviewed by: plam diff --git a/src/fccache.c b/src/fccache.c index 0bbfffe..e761f36 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -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