summaryrefslogtreecommitdiff
path: root/src/fccache.c
diff options
context:
space:
mode:
authorPatrick Lam <plam@MIT.EDU>2006-04-10 15:46:34 +0000
committerPatrick Lam <plam@MIT.EDU>2006-04-10 15:46:34 +0000
commitae2aafe6028be658bd1de0fe2dd309799bf575f7 (patch)
tree20c7282b163e6986a107467077ece4f48b41eef5 /src/fccache.c
parent86abd75965f598dba79a3df68e7bc4c5082a5764 (diff)
Fix double free (spotted by Coverity, CID #1965).
Check if pattern is not null before using it (Coverity defect #1883). Fix memory leak with hash collision (Coverity defect #1829). Fix memory leak when bail cases (Coverity defect #1828). Don't leak directory name (Coverity defect #1827). reviewed by: plam
Diffstat (limited to 'src/fccache.c')
-rw-r--r--src/fccache.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/fccache.c b/src/fccache.c
index 248c6d1..de95f36 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -236,7 +236,7 @@ FcGlobalCacheLoad (FcGlobalCache *cache,
FcCache md;
off_t off;
- FcStrSetAdd (staleDirs, FcStrCopy ((FcChar8 *)name_buf));
+ FcStrSetAdd (staleDirs, (FcChar8 *)name_buf);
/* skip subdirs */
while (FcCacheReadString (cache->fd, subdirName,
@@ -1311,12 +1311,16 @@ FcDirCacheWrite (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir)
if(!FcCacheReadString (fd, name_buf, sizeof (name_buf)) || !strlen(name_buf))
{
close (fd);
+ FcStrFree ((FcChar8 *)cache_hashed);
continue;
}
close (fd);
- if (strcmp (name_buf, cache_file) != 0)
+ if (strcmp (name_buf, cache_file) != 0)
+ {
+ FcStrFree ((FcChar8 *)cache_hashed);
continue;
+ }
break;
} while (1);
@@ -1445,7 +1449,7 @@ FcDirCacheWrite (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir)
free (header);
close(fd);
if (!FcAtomicReplaceOrig(atomic))
- goto bail5;
+ goto bail3;
FcStrFree ((FcChar8 *)cache_hashed);
FcStrFree ((FcChar8 *)cache_file);
FcAtomicUnlock (atomic);