GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: fix Windows segfault with `--eval` · nodejs/node@cd38401

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_main.cc
  • test/parallel
    • test-cli-eval.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_main.cc‎

Copy file name to clipboardExpand all lines: src/node_main.cc
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ int wmain(int argc, wchar_t *wargv[]) {
1111
}
1212

1313
// Convert argv to to UTF8
14-
char** argv = new char*[argc];
14+
char** argv = new char*[argc + 1];
1515
for (int i = 0; i < argc; i++) {
1616
// Compute the size of the required buffer
1717
DWORD size = WideCharToMultiByte(CP_UTF8,
@@ -43,6 +43,7 @@ int wmain(int argc, wchar_t *wargv[]) {
4343
exit(1);
4444
}
4545
}
46+
argv[argc] = nullptr;
4647
// Now that conversion is done, we can finally start.
4748
return node::Start(argc, argv);
4849
}
Collapse file

‎test/parallel/test-cli-eval.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-cli-eval.js
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ child.exec(nodejs + ' --eval "console.error(42)"',
4040
assert.equal(stderr, '');
4141
});
4242

43-
child.exec(cmd + "'[]'",
43+
child.exec(cmd + "'[]'", common.mustCall(
4444
function(err, stdout, stderr) {
4545
assert.equal(stdout, '[]\n');
4646
assert.equal(stderr, '');
47-
});
47+
}));
4848
});
4949

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

69+
// Missing argument should not crash
70+
child.exec(nodejs + ' -e', common.mustCall(function(status, stdout, stderr) {
71+
assert.notStrictEqual(status, null);
72+
assert.strictEqual(status.code, 9);
73+
}));
74+
6975
// empty program should do nothing
7076
child.exec(nodejs + ' -e ""', function(status, stdout, stderr) {
7177
assert.equal(stdout, '');

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.