summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@neko.keithp.com>2006-09-01 12:07:10 -0700
committerKeith Packard <keithp@neko.keithp.com>2006-09-01 12:07:10 -0700
commit1741499e2387f0c1e692801a1ef3c6ce5d043f9f (patch)
tree65f373cdf3fd6d3e716873b91784aa719fdf714d
parentfd7223c770e74730480bdf9ecf36f3152a12473e (diff)
Fix memory leaks in fc-cache directory cleaning code.
valgrind found a few leaks in the new cache cleaning code.
-rw-r--r--fc-cache/fc-cache.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c
index 6957a65b..06864810 100644
--- a/fc-cache/fc-cache.c
+++ b/fc-cache/fc-cache.c
@@ -287,10 +287,16 @@ cleanCacheDirectory (FcConfig *config, FcChar8 *dir, FcBool verbose)
struct stat target_stat;
dir_base = FcStrPlus (dir, "/");
+ if (!dir_base)
+ {
+ fprintf (stderr, "%s: out of memory\n", dir);
+ return FcFalse;
+ }
if (access ((char *) dir, W_OK|X_OK) != 0)
{
if (verbose)
printf ("%s: not cleaning unwritable cache directory\n", dir);
+ FcStrFree (dir_base);
return FcTrue;
}
if (verbose)
@@ -299,6 +305,7 @@ cleanCacheDirectory (FcConfig *config, FcChar8 *dir, FcBool verbose)
if (!d)
{
perror (dir);
+ FcStrFree (dir_base);
return FcFalse;
}
while ((ent = readdir (d)))
@@ -347,10 +354,12 @@ cleanCacheDirectory (FcConfig *config, FcChar8 *dir, FcBool verbose)
ret = FcFalse;
}
}
+ FcDirCacheUnload (cache);
FcStrFree (file_name);
}
closedir (d);
+ FcStrFree (dir_base);
return ret;
}