summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--win32/win32.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 8a59bf9cca..72234c4cc4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Dec 5 18:13:39 2008 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (rb_w32_isatty): check whether fd is valid.
+
Fri Dec 5 12:49:24 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (waitpid): fix bug of checking child slot.
diff --git a/win32/win32.c b/win32/win32.c
index 9d46bf0d6d..de90cfb144 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -4091,6 +4091,10 @@ rb_w32_unlink(const char *path)
int
rb_w32_isatty(int fd)
{
+ // validate fd by using _get_osfhandle() because we cannot access _nhandle
+ if (_get_osfhandle(fd) == -1) {
+ return 0;
+ }
if (!(_osfile(fd) & FOPEN)) {
errno = EBADF;
return 0;