diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 593aea641b2bf3..307d4639d410f8 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -3262,14 +3262,16 @@ Maybe Value::IntegerValue(Local context) const { i::Handle num; if (obj->IsNumber()) { num = obj; + return Just(num->IsSmi() ? static_cast(i::Smi::cast(*num)->value()) + : static_cast(num->Number())); } else { PREPARE_FOR_EXECUTION_PRIMITIVE(context, "IntegerValue", int64_t); has_pending_exception = !i::Execution::ToInteger(isolate, obj).ToHandle(&num); RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int64_t); + return Just(num->IsSmi() ? static_cast(i::Smi::cast(*num)->value()) + : static_cast(num->Number())); } - return Just(num->IsSmi() ? static_cast(i::Smi::cast(*num)->value()) - : static_cast(num->Number())); } diff --git a/test/parallel/test-child-process-stdio.js b/test/parallel/test-child-process-stdio.js index 1ff6e4d914f7ec..eab508e7fe559c 100644 --- a/test/parallel/test-child-process-stdio.js +++ b/test/parallel/test-child-process-stdio.js @@ -18,3 +18,8 @@ assert.equal(child.stderr, null); options = {stdio: 'ignore'}; child = common.spawnSyncCat(options); assert.deepEqual(options, {stdio: 'ignore'}); + +// This should never cause segmentation faults +// cf. https://github.com/nodejs/node/issues/2721 +options = {stdio: [process.stdin, process.stdout, process.stderr]}; +child = common.spawnPwd(options);