diff --git a/src/win/fs.c b/src/win/fs.c index 164907e0432..eec3c1c84bd 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -316,7 +316,11 @@ static int fs__readlink_handle(HANDLE handle, } assert(target_ptr == NULL || *target_ptr == NULL); - return uv_utf16_to_wtf8(w_target, w_target_len, target_ptr, target_len_ptr); + if (uv_utf16_to_wtf8(w_target, w_target_len, target_ptr, target_len_ptr) != 0) { + SetLastError(ERROR_OUTOFMEMORY); + return -1; + } + return 0; } @@ -709,7 +713,7 @@ LONG fs__filemap_ex_filter(LONG excode, PEXCEPTION_POINTERS pep, assert(perror != NULL); if (pep != NULL && pep->ExceptionRecord != NULL && pep->ExceptionRecord->NumberParameters >= 3) { - NTSTATUS status = (NTSTATUS)pep->ExceptionRecord->ExceptionInformation[3]; + NTSTATUS status = (NTSTATUS)pep->ExceptionRecord->ExceptionInformation[2]; *perror = pRtlNtStatusToDosError(status); if (*perror != ERROR_SUCCESS) { return EXCEPTION_EXECUTE_HANDLER; @@ -3038,7 +3042,11 @@ static ssize_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) { assert(*realpath_ptr == NULL); r = uv_utf16_to_wtf8(w_realpath_ptr, w_realpath_len, realpath_ptr, NULL); uv__free(w_realpath_buf); - return r; + if (r != 0) { + SetLastError(ERROR_OUTOFMEMORY); + return -1; + } + return 0; } static void fs__realpath(uv_fs_t* req) { diff --git a/src/win/pipe.c b/src/win/pipe.c index 05c224c7b3b..7ddab554f36 100644 --- a/src/win/pipe.c +++ b/src/win/pipe.c @@ -398,10 +398,10 @@ int uv_pipe(uv_file fds[2], int read_flags, int write_flags) { 0, (uintptr_t) &fds[0]); if (err != 0) - return err; + return uv_translate_sys_error(err); temp[0] = _open_osfhandle((intptr_t) readh, 0); if (temp[0] == -1) { - if (errno == UV_EMFILE) + if (errno == EMFILE) err = UV_EMFILE; else err = UV_UNKNOWN; @@ -411,7 +411,7 @@ int uv_pipe(uv_file fds[2], int read_flags, int write_flags) { } temp[1] = _open_osfhandle((intptr_t) writeh, 0); if (temp[1] == -1) { - if (errno == UV_EMFILE) + if (errno == EMFILE) err = UV_EMFILE; else err = UV_UNKNOWN; @@ -2266,7 +2266,7 @@ void uv__process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle, uv__free(coalesced_write); } if (req->cb) { - req->cb(req, uv_translate_sys_error(err)); + req->cb(req, uv_translate_write_sys_error(err)); } handle->stream.conn.write_reqs_pending--; diff --git a/src/win/tty.c b/src/win/tty.c index f8fcdbad5b9..7776ae749fb 100644 --- a/src/win/tty.c +++ b/src/win/tty.c @@ -1262,6 +1262,7 @@ static int uv__tty_move_caret(uv_tty_t* handle, int x, unsigned char x_relative, retry: if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { *error = GetLastError(); + return -1; } pos = uv__tty_make_real_coord(handle, &info, x, x_relative, y, y_relative);