Skip to content

Commit 4118598

Browse files
seishunevanlucas
authored andcommitted
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>
1 parent 92de0bc commit 4118598

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/node.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,10 @@ static void PrintErrorString(const char* format, ...) {
258258

259259
std::vector<wchar_t> wbuf(n);
260260
MultiByteToWideChar(CP_UTF8, 0, out.data(), -1, wbuf.data(), n);
261-
WriteConsoleW(stderr_handle, wbuf.data(), n, nullptr, nullptr);
261+
262+
// Don't include the null character in the output
263+
CHECK_GT(n, 0);
264+
WriteConsoleW(stderr_handle, wbuf.data(), n - 1, nullptr, nullptr);
262265
#else
263266
vfprintf(stderr, format, ap);
264267
#endif

0 commit comments

Comments
 (0)