aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2008-03-24 05:34:58 -0500
committerRob Landley <rob@landley.net>2008-03-24 05:34:58 -0500
commit603a93d3f04e3f713c5e64d10464720018c51f29 (patch)
treeac93c21ee3de07a3b696d91a060f7dcdef1e7667 /lib
parent4416caef3dea3541c112785d1b61d0c11ec8d11e (diff)
downloadtoybox-603a93d3f04e3f713c5e64d10464720018c51f29.tar.gz
If we don't remember to closedir(), the leaked filehandles add up.
Diffstat (limited to 'lib')
-rw-r--r--lib/dirtree.c8
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]=='.') {