Skip to content

Commit

Permalink
js_stream: prevent abort if isalive doesn't exist
Browse files Browse the repository at this point in the history
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: #3282
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
  • Loading branch information
trevnorris committed Oct 8, 2015
1 parent 26a7ec6 commit 1850879
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/js_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


Expand Down
8 changes: 8 additions & 0 deletions test/parallel/test-js-stream-call-properties.js
Original file line number Diff line number Diff line change
@@ -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());

0 comments on commit 1850879

Please sign in to comment.