Skip to content

Commit 0834c75

Browse files
seishunMyles Borins
authored and
Myles Borins
committed
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 8cf044a commit 0834c75

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
@@ -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)