Skip to content
Open
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
6 changes: 6 additions & 0 deletions src/process_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ class ProcessWrap : public HandleWrap {
if (!stdios->Get(context, i).ToLocal(&val)) {
return Nothing<void>();
}
if (!val->IsObject()) {
THROW_ERR_INVALID_ARG_TYPE(env,
"options.stdio[%u] must be an object",
i);
return Nothing<void>();
}
Local<Object> stdio = val.As<Object>();
Local<Value> type;
if (!stdio->Get(context, env->type_string()).ToLocal(&type)) {
Expand Down
29 changes: 29 additions & 0 deletions test/parallel/test-child-process-array-prototype-setter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';
require('../common');

const assert = require('assert');
const { spawnSyncAndAssert } = require('../common/child_process');

const script = `
Object.defineProperty(Array.prototype, '2', {
__proto__: null,
set() {},
configurable: true,
});
try {
require('child_process').spawn(process.execPath, ['-e', '0']);
console.log('NO_ERROR');
} catch (error) {
console.log(error.code);
}
`;

spawnSyncAndAssert(process.execPath, ['-e', script], {
stdout: (output) => {
assert.match(output, /^ERR_INVALID_ARG_TYPE\\r?\\n$/);
},
stderr: (output) => {
assert.doesNotMatch(output, /FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal/);
},
});