win,tty: convert fd -> handle safely
_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é <saghul@gmail.com>
This commit is contained in:
parent
90fb8cb0ab
commit
0bad50a09c
@ -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. */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user