diff options
Diffstat (limited to 'lib/dirtree.c')
-rw-r--r-- | lib/dirtree.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/dirtree.c b/lib/dirtree.c index 6cdacfe6..45ee139c 100644 --- a/lib/dirtree.c +++ b/lib/dirtree.c @@ -57,10 +57,12 @@ struct dirtree *dirtree_read(char *path, struct dirtree *parent, int len = strlen(path); if (!(dir = opendir(path))) perror_msg("No %s", path); - - for (;;) { + else for (;;) { struct dirent *entry = readdir(dir); - if (!entry) break; + if (!entry) { + closedir(dir); + break; + } // Skip "." and ".." if (entry->d_name[0]=='.') { |