rosh: closedir() only if actually opened
authorGene Cumm <gene.cumm@gmail.com>
Sat, 2 Oct 2010 04:18:27 +0000 (00:18 -0400)
committerGene Cumm <gene.cumm@gmail.com>
Sat, 9 Oct 2010 11:33:07 +0000 (07:33 -0400)
com32/rosh/rosh.c

index f5ed6cd..8d063e6 100644 (file)
@@ -780,11 +780,11 @@ void rosh_ls_arg(const char *filestr, const int *optarr)
            ROSH_DEBUG("PATH '%s' is a directory\n", filestr);
            if (d = opendir(filestr)) {
                rosh_ls_arg_dir(filestr, d, optarr);
+               closedir(d);
            } else {
                rosh_error(errno, "ls", filestr);
                errno = 0;
            }
-           closedir(d);
        } else {
            de.d_ino = rosh_ls_d_ino(&fdstat);
            de.d_type = (IFTODT(fdstat.st_mode));