Permalink
Browse files

src: don't include a null character in the WriteConsoleW call

Fixes: #7755
PR-URL: #7764
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information...
seishun authored and jasnell committed Jul 16, 2016
1 parent f7a23a2 commit 09f861f231e6421f6f7cd8f8de4f3a05df8b204f
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/node.cc
View
@@ -257,7 +257,10 @@ static void PrintErrorString(const char* format, ...) {
std::vector<wchar_t> wbuf(n);
MultiByteToWideChar(CP_UTF8, 0, out.data(), -1, wbuf.data(), n);
WriteConsoleW(stderr_handle, wbuf.data(), n, nullptr, nullptr);
// Don't include the null character in the output
CHECK_GT(n, 0);
WriteConsoleW(stderr_handle, wbuf.data(), n - 1, nullptr, nullptr);
#else
vfprintf(stderr, format, ap);
#endif

0 comments on commit 09f861f

Please sign in to comment.