Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix windows segfault #6938

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/node_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int wmain(int argc, wchar_t *wargv[]) {
}

// Convert argv to to UTF8
char** argv = new char*[argc];
char** argv = new char*[argc + 1];
for (int i = 0; i < argc; i++) {
// Compute the size of the required buffer
DWORD size = WideCharToMultiByte(CP_UTF8,
Expand Down Expand Up @@ -43,6 +43,7 @@ int wmain(int argc, wchar_t *wargv[]) {
exit(1);
}
}
argv[argc] = nullptr;
// Now that conversion is done, we can finally start.
return node::Start(argc, argv);
}
Expand Down
10 changes: 8 additions & 2 deletions test/parallel/test-cli-eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ child.exec(nodejs + ' --eval "console.error(42)"',
assert.equal(stderr, '');
});

child.exec(cmd + "'[]'",
child.exec(cmd + "'[]'", common.mustCall(
function(err, stdout, stderr) {
assert.equal(stdout, '[]\n');
assert.equal(stderr, '');
});
}));
});

// assert that module loading works
Expand All @@ -66,6 +66,12 @@ child.exec(nodejs + ' --eval "require(\'./test/parallel/test-cli-eval.js\')"',
assert.equal(status.code, 42);
});

// Missing argument should not crash
child.exec(nodejs + ' -e', function(status, stdout, stderr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the assertion happens within the callback, its better to use common.mustCall

assert.notStrictEqual(status, null);
assert.strictEqual(status.code, 9);
});

// empty program should do nothing
child.exec(nodejs + ' -e ""', function(status, stdout, stderr) {
assert.equal(stdout, '');
Expand Down