summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/win32/win32.c b/win32/win32.c
index abe3949600..944ff3a931 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -4088,6 +4088,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;