summaryrefslogtreecommitdiff
path: root/winsup/cygwin/fhandler_virtual.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/fhandler_virtual.cc')
-rw-r--r--winsup/cygwin/fhandler_virtual.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/winsup/cygwin/fhandler_virtual.cc b/winsup/cygwin/fhandler_virtual.cc
index fe83f90e8a3..420544d6152 100644
--- a/winsup/cygwin/fhandler_virtual.cc
+++ b/winsup/cygwin/fhandler_virtual.cc
@@ -74,16 +74,19 @@ fhandler_virtual::opendir ()
strcpy (dir->__d_dirname, get_name ());
dir->__d_dirent->d_version = __DIRENT_VERSION;
cygheap_fdnew fd;
- fd = this;
- fd->set_nohandle (true);
- dir->__d_dirent->d_fd = fd;
- dir->__d_u.__d_data.__fh = this;
- dir->__d_cookie = __DIRENT_COOKIE;
- dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE;
- dir->__d_position = 0;
- dir->__d_dirhash = get_namehash ();
-
- res = dir;
+ if (fd >= 0)
+ {
+ fd = this;
+ fd->set_nohandle (true);
+ dir->__d_dirent->d_fd = fd;
+ dir->__d_u.__d_data.__fh = this;
+ dir->__d_cookie = __DIRENT_COOKIE;
+ dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE;
+ dir->__d_position = 0;
+ dir->__d_dirhash = get_namehash ();
+
+ res = dir;
+ }
}
syscall_printf ("%p = opendir (%s)", res, get_name ());