From 0bad50a09c6c7a47e944df940ea995e30305be70 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Wed, 10 Jun 2015 11:33:52 -0700 Subject: [PATCH] win,tty: convert fd -> handle safely MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _get_osfhandle() may throw if it's used to convert a non-open file descriptor to a Windows HANDLE. Use the safe uv__get_osfhandle instead. PR-URL: https://github.com/libuv/libuv/pull/396 Reviewed-By: Saúl Ibarra Corretgé --- src/win/tty.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/win/tty.c b/src/win/tty.c index 7b1e4ba0..78176849 100644 --- a/src/win/tty.c +++ b/src/win/tty.c @@ -106,10 +106,9 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) { HANDLE handle; CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info; - handle = (HANDLE) _get_osfhandle(fd); - if (handle == INVALID_HANDLE_VALUE) { + handle = (HANDLE) uv__get_osfhandle(fd); + if (handle == INVALID_HANDLE_VALUE) return UV_EBADF; - } if (!readable) { /* Obtain the screen buffer info with the output handle. */