Skip to content

Commit 606deec

Browse files
seishunMylesBorins
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 a8a8f0a commit 606deec

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/node.cc

+4-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,10 @@ static void PrintErrorString(const char* format, ...) {
192192

193193
std::vector<wchar_t> wbuf(n);
194194
MultiByteToWideChar(CP_UTF8, 0, out.data(), -1, wbuf.data(), n);
195-
WriteConsoleW(stderr_handle, wbuf.data(), n, nullptr, nullptr);
195+
196+
// Don't include the null character in the output
197+
CHECK_GT(n, 0);
198+
WriteConsoleW(stderr_handle, wbuf.data(), n - 1, nullptr, nullptr);
196199
#else
197200
vfprintf(stderr, format, ap);
198201
#endif

0 commit comments

Comments
 (0)