From 52b49b399e0b119e63cc3f918485ece23c097de6 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Wed, 18 Feb 2009 13:27:18 +0000 Subject: merge revision(s) 20540: * win32/win32.c (rb_w32_isatty): check whether fd is valid. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@22416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- win32/win32.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'win32') diff --git a/win32/win32.c b/win32/win32.c index 5fd4678383..91b4ea89b8 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -3911,6 +3911,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; -- cgit v1.2.3