OSDN Git Service

* dtable.cc (dtable::init_std_file_from_handle): Add some defensive code to
authorcgf <cgf>
Sun, 6 Jan 2002 17:29:41 +0000 (17:29 +0000)
committercgf <cgf>
Sun, 6 Jan 2002 17:29:41 +0000 (17:29 +0000)
invalid handle case.

winsup/cygwin/ChangeLog
winsup/cygwin/dtable.cc

index 091c256..de4e329 100644 (file)
@@ -1,3 +1,8 @@
+2002-01-06  Christopher Faylor  <cgf@redhat.com>
+
+       * dtable.cc (dtable::init_std_file_from_handle): Add some defensive
+       code to invalid handle case.
+
 2002-01-06  Corinna Vinschen  <corinna@vinschen.de>
 
        * ioctl.cc (ioctl): Make third argument optional.
index a6f5b07..e7e9fd2 100644 (file)
@@ -91,8 +91,8 @@ dtable::extend (int howmuch)
 }
 
 /* Initialize the file descriptor/handle mapping table.
-   We only initialize the parent table here.  The child table is
-   initialized at each fork () call.  */
+   This function should only be called when a cygwin function is invoked
+   by a non-cygwin function, i.e., it should only happen very rarely. */
 
 void
 stdio_init (void)
@@ -197,7 +197,10 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle, DWORD myaccess)
   first_fd_for_open = 0;
 
   if (!handle || handle == INVALID_HANDLE_VALUE)
-    return;
+    {
+      fds[fd] = NULL;
+      return;
+    }
 
   if (__fmode)
     bin = __fmode;