diff --git a/src/node_internals.h b/src/node_internals.h index ced62e08b6..d9db29c1b7 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -318,6 +318,7 @@ v8::Handle MakeCallback( inline bool HasInstance( const v8::Persistent& function_template, v8::Handle value) { + if (function_template.IsEmpty()) return false; v8::Local function_template_handle = PersistentToLocal(node_isolate, function_template); return function_template_handle->HasInstance(value); diff --git a/src/node_wrap.h b/src/node_wrap.h index 7c3f63fb20..c5fe0fccd7 100644 --- a/src/node_wrap.h +++ b/src/node_wrap.h @@ -38,16 +38,13 @@ extern v8::Persistent tcpConstructorTmpl; #define WITH_GENERIC_STREAM(obj, BODY) \ do { \ - if (!tcpConstructorTmpl.IsEmpty() && \ - HasInstance(tcpConstructorTmpl, obj)) { \ + if (HasInstance(tcpConstructorTmpl, obj)) { \ TCPWrap* wrap = TCPWrap::Unwrap(obj); \ BODY \ - } else if (!ttyConstructorTmpl.IsEmpty() && \ - HasInstance(ttyConstructorTmpl, obj)) { \ + } else if (HasInstance(ttyConstructorTmpl, obj)) { \ TTYWrap* wrap = TTYWrap::Unwrap(obj); \ BODY \ - } else if (!pipeConstructorTmpl.IsEmpty() && \ - HasInstance(pipeConstructorTmpl, obj)) { \ + } else if (HasInstance(pipeConstructorTmpl, obj)) { \ PipeWrap* wrap = PipeWrap::Unwrap(obj); \ BODY \ } \