js_stream: prevent abort if isalive doesn't exist
Attempting to check IsAlive() on a JSStream before the isAlive() callback can be set in JS causes a CHECK to fail in MakeCallback. Instead return false if the callback hasn't been set. PR-URL: https://github.com/nodejs/node/pull/3282 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
This commit is contained in:
parent
ded4f91eef
commit
178ac3367f
@ -44,7 +44,10 @@ AsyncWrap* JSStream::GetAsyncWrap() {
|
||||
|
||||
|
||||
bool JSStream::IsAlive() {
|
||||
return MakeCallback(env()->isalive_string(), 0, nullptr)->IsTrue();
|
||||
v8::Local<v8::Value> fn = object()->Get(env()->isalive_string());
|
||||
if (!fn->IsFunction())
|
||||
return false;
|
||||
return MakeCallback(fn.As<v8::Function>(), 0, nullptr)->IsTrue();
|
||||
}
|
||||
|
||||
|
||||
|
8
test/parallel/test-js-stream-call-properties.js
Normal file
8
test/parallel/test-js-stream-call-properties.js
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const util = require('util');
|
||||
const JSStream = process.binding('js_stream').JSStream;
|
||||
|
||||
// Testing if will abort when properties are printed.
|
||||
util.inspect(new JSStream());
|
Loading…
x
Reference in New Issue
Block a user