Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
dtrace: check if _handle property is set
Browse files Browse the repository at this point in the history
Check that _handle is an object before trying to read its `fd`
property, avoids bogus values.
  • Loading branch information
bnoordhuis committed Mar 30, 2013
1 parent aa5da48 commit 9b8dd39
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/node_dtrace.cc
Expand Up @@ -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);
Expand Down

0 comments on commit 9b8dd39

Please sign in to comment.