Skip to content

Commit 09f861f

Browse files
seishunjasnell
authored andcommitted
src: don't include a null character in the WriteConsoleW call
Fixes: #7755 PR-URL: #7764 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent f7a23a2 commit 09f861f

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
@@ -257,7 +257,10 @@ static void PrintErrorString(const char* format, ...) {
257257

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

0 commit comments

Comments
 (0)