diff options
author | Timothy Arceri <[email protected]> | 2017-02-22 14:16:04 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-02-23 09:20:22 +1100 |
commit | d258055c8bcb1bd8438b4c28134813a4f0620f98 (patch) | |
tree | 97adf67b722b083093316cf88d0b9624368c0164 /src/util | |
parent | 8e03250fcf4fc5de31e92ca4919959d932888a69 (diff) |
util/disk_cache: fix bug with deleting old cache dirs
If there was more than a single directory in the .cache/mesa dir
then it would only remove one (or none) of the directories.
Apparently Valgrind was also reporting:
Conditional jump or move depends on uninitialised value
Reviewed-by: Edward O'Callaghan <[email protected]>
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/disk_cache.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c index 2f138dab19b..f5e114513e0 100644 --- a/src/util/disk_cache.c +++ b/src/util/disk_cache.c @@ -152,17 +152,19 @@ remove_old_cache_directories(void *mem_ctx, char *path, const char *timestamp) struct dirent* d_entry; while((d_entry = readdir(dir)) != NULL) { + char *full_path = + ralloc_asprintf(mem_ctx, "%s/%s", path, d_entry->d_name); + struct stat sb; - stat(d_entry->d_name, &sb); - if (S_ISDIR(sb.st_mode) && + if (stat(full_path, &sb) == 0 && S_ISDIR(sb.st_mode) && strcmp(d_entry->d_name, timestamp) != 0 && strcmp(d_entry->d_name, "..") != 0 && strcmp(d_entry->d_name, ".") != 0) { - char *full_path = - ralloc_asprintf(mem_ctx, "%s/%s", path, d_entry->d_name); nftw(full_path, remove_dir, 20, FTW_DEPTH); } } + + closedir(dir); } static char * |