Skip to content

Commit 7546389

Browse files
bnoordhuisisaacs
authored andcommitted
dtrace: check if _handle property is set
Check that _handle is an object before trying to read its `fd` property, avoids bogus values.
1 parent aca31e3 commit 7546389

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/node_dtrace.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ using namespace v8;
9191
} \
9292
node_dtrace_connection_t conn; \
9393
Local<Object> _##conn = Local<Object>::Cast(arg); \
94-
Local<Object> _handle = (_##conn)->Get(String::New("_handle"))->ToObject(); \
95-
SLURP_INT(_handle, fd, &conn.fd); \
94+
Local<Value> _handle = (_##conn)->Get(String::New("_handle")); \
95+
if (_handle->IsObject()) { \
96+
SLURP_INT(_handle.As<Object>(), fd, &conn.fd); \
97+
} else { \
98+
conn.fd = -1; \
99+
} \
96100
SLURP_STRING(_##conn, remoteAddress, &conn.remote); \
97101
SLURP_INT(_##conn, remotePort, &conn.port); \
98102
SLURP_INT(_##conn, bufferSize, &conn.buffered);

0 commit comments

Comments
 (0)