diff options
author | Rob Landley <rob@landley.net> | 2008-03-24 05:34:58 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2008-03-24 05:34:58 -0500 |
commit | 603a93d3f04e3f713c5e64d10464720018c51f29 (patch) | |
tree | ac93c21ee3de07a3b696d91a060f7dcdef1e7667 | |
parent | 4416caef3dea3541c112785d1b61d0c11ec8d11e (diff) | |
download | toybox-603a93d3f04e3f713c5e64d10464720018c51f29.tar.gz |
If we don't remember to closedir(), the leaked filehandles add up.
-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]=='.') { |