From e58b50e88cbe3b55695101a0988306ea4646bbe4 Mon Sep 17 00:00:00 2001 From: Patrick Lam Date: Fri, 21 Oct 2005 20:24:30 +0000 Subject: [PATCH] Destroy the global cache file if it's terminally broken. (reported by Mike Fabian) --- ChangeLog | 9 ++++++++- src/fccache.c | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) 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