Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1850879

Browse filesBrowse files
committed
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: #3282 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
1 parent 26a7ec6 commit 1850879
Copy full SHA for 1850879

File tree

Expand file treeCollapse file tree

2 files changed

+12
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-1
lines changed
Open diff view settings
Collapse file

‎src/js_stream.cc‎

Copy file name to clipboardExpand all lines: src/js_stream.cc
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ AsyncWrap* JSStream::GetAsyncWrap() {
4444

4545

4646
bool JSStream::IsAlive() {
47-
return MakeCallback(env()->isalive_string(), 0, nullptr)->IsTrue();
47+
v8::Local<v8::Value> fn = object()->Get(env()->isalive_string());
48+
if (!fn->IsFunction())
49+
return false;
50+
return MakeCallback(fn.As<v8::Function>(), 0, nullptr)->IsTrue();
4851
}
4952

5053

Collapse file
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const util = require('util');
5+
const JSStream = process.binding('js_stream').JSStream;
6+
7+
// Testing if will abort when properties are printed.
8+
util.inspect(new JSStream());

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.