Skip to content

Commit

Permalink
src: fix winapi_strerror error string
Browse files Browse the repository at this point in the history
Fixes: #23191
  • Loading branch information
huseyinacacak-janea committed Oct 1, 2024
1 parent d17fefc commit 95c8b00
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/api/exceptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ Local<Value> UVException(Isolate* isolate,
static const char* winapi_strerror(const int errorno, bool* must_free) {
char* errmsg = nullptr;

FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr,
errorno,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
reinterpret_cast<LPTSTR>(&errmsg),
reinterpret_cast<LPSTR>(&errmsg),
0,
nullptr);

Expand Down
43 changes: 43 additions & 0 deletions test/parallel/test-print-GH-23191.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
const common = require('../common');
const { strictEqual } = require('assert');

// Ref: https://github.com/nodejs/node/issues/23191
// This test is specific to Windows.

async function testDebugPrint() {

const child = require('child_process');
const cp = child.spawnSync(process.execPath,
['-e', 'console.log("Hello World");']);
try {
process._debugProcess(cp.pid);
} catch (error) {
strictEqual(error.message, 'The parameter is incorrect.');
}
}

if (common.isWindows) {
testDebugPrint().then(common.mustCall());
}

0 comments on commit 95c8b00

Please sign in to comment.