Skip to content

Commit

Permalink
v8: fix segmentation faults caused by IntegerValue
Browse files Browse the repository at this point in the history
  • Loading branch information
pmq20 committed Sep 7, 2015
1 parent 6efb697 commit 958fe12
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions deps/v8/src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3262,14 +3262,16 @@ Maybe<int64_t> Value::IntegerValue(Local<Context> context) const {
i::Handle<i::Object> num;
if (obj->IsNumber()) {
num = obj;
return Just(num->IsSmi() ? static_cast<int64_t>(i::Smi::cast(*num)->value())
: static_cast<int64_t>(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<int64_t>(i::Smi::cast(*num)->value())
: static_cast<int64_t>(num->Number()));
}
return Just(num->IsSmi() ? static_cast<int64_t>(i::Smi::cast(*num)->value())
: static_cast<int64_t>(num->Number()));
}


Expand Down
5 changes: 5 additions & 0 deletions test/parallel/test-child-process-stdio.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 958fe12

Please sign in to comment.