diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-03-30 04:49:19 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-04-03 20:52:56 +0400 |
commit | 75463899c8ef90e5a429cb1dcd578ee2886e71d4 (patch) | |
tree | 46ae5bcca7a035ebdbfd1c9006a111264bfa13f9 /src | |
parent | aca31e37f7bccbf229f460b236753072eecfeeab (diff) |
dtrace: check if _handle property is set
Check that _handle is an object before trying to read its `fd`
property, avoids bogus values.
Diffstat (limited to 'src')
-rw-r--r-- | src/node_dtrace.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/node_dtrace.cc b/src/node_dtrace.cc index 9770ae23774..4318e8b49c8 100644 --- a/src/node_dtrace.cc +++ b/src/node_dtrace.cc @@ -91,8 +91,12 @@ using namespace v8; } \ node_dtrace_connection_t conn; \ Local<Object> _##conn = Local<Object>::Cast(arg); \ - Local<Object> _handle = (_##conn)->Get(String::New("_handle"))->ToObject(); \ - SLURP_INT(_handle, fd, &conn.fd); \ + Local<Value> _handle = (_##conn)->Get(String::New("_handle")); \ + if (_handle->IsObject()) { \ + SLURP_INT(_handle.As<Object>(), fd, &conn.fd); \ + } else { \ + conn.fd = -1; \ + } \ SLURP_STRING(_##conn, remoteAddress, &conn.remote); \ SLURP_INT(_##conn, remotePort, &conn.port); \ SLURP_INT(_##conn, bufferSize, &conn.buffered); |