From 47f9ee35819c4259edc75dac1f6adf414ae6808b Mon Sep 17 00:00:00 2001 From: Rob Kendrick Date: Sun, 10 Jun 2007 11:28:44 +0000 Subject: Check return value of stat() in filename.c and report oddness using LOG svn path=/trunk/netsurf/; revision=3318 --- utils/filename.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'utils') diff --git a/utils/filename.c b/utils/filename.c index 52caa1e41..ce8afc00e 100644 --- a/utils/filename.c +++ b/utils/filename.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -225,7 +226,10 @@ bool filename_flush_directory(const char *folder, int depth) { continue; snprintf(child, 256, "%s/%s", folder, entry->d_name); - stat(child, &statbuf); + if (stat(child, &statbuf) == -1) { + LOG(("Unable to stat %s, even though it just got returned from readdir(): %s", child, strerror(errno))); + continue; + } /* first 3 depths are directories only, then files only */ if (depth < 3) @@ -309,7 +313,11 @@ bool filename_delete_recursive(char *folder) { (!strcmp(entry->d_name, ".."))) continue; snprintf(child, 256, "%s/%s", folder, entry->d_name); - stat(child, &statbuf); + if (stat(child, &statbuf) == -1) { + LOG(("Unable to stat %s, even though it just got returned from readdir(): %s", child, strerror(errno))); + continue; + + } if (S_ISDIR(statbuf.st_mode)) { if (!filename_delete_recursive(child)) { closedir(parent); -- cgit v1.2.3