summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/dir.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/dir.cc')
-rw-r--r--winsup/cygwin/dir.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
index 44db5d7be..40411b48c 100644
--- a/winsup/cygwin/dir.cc
+++ b/winsup/cygwin/dir.cc
@@ -88,14 +88,16 @@ opendir (const char *name)
PC_SYM_FOLLOW | PC_FULL, NULL);
if (!fh)
res = NULL;
- else if (!pc.exists ())
- set_errno (ENOENT);
+ else if (pc.exists ())
+ res = fh->opendir (pc);
else
{
- res = fh->opendir (pc);
- if (!res)
- delete fh;
+ set_errno (ENOENT);
+ res = NULL;
}
+
+ if (!res && fh)
+ delete fh;
return res;
}