diff --git a/src/node.cc b/src/node.cc index 00ab762b4bbeef..23b1009616466f 100644 --- a/src/node.cc +++ b/src/node.cc @@ -192,7 +192,10 @@ static void PrintErrorString(const char* format, ...) { std::vector 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