Skip to content

Commit

Permalink
src: don't include a null character in the WriteConsoleW call
Browse files Browse the repository at this point in the history
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 MylesBorins committed Oct 26, 2016
1 parent a8a8f0a commit 606deec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,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
Expand Down

0 comments on commit 606deec

Please sign in to comment.