Fix Node crash from calling function with empty this
This commit is contained in:
parent
8602787fc9
commit
ca87f5a3e0
|
@ -26,7 +26,9 @@ namespace js {
|
|||
template<>
|
||||
inline v8::Local<v8::Value> node::Function::call(v8::Isolate* isolate, const v8::Local<v8::Function> &function, const v8::Local<v8::Object> &this_object, size_t argc, const v8::Local<v8::Value> arguments[]) {
|
||||
Nan::TryCatch trycatch;
|
||||
auto result = Nan::Call(function, this_object, (int)argc, const_cast<v8::Local<v8::Value>*>(arguments));
|
||||
|
||||
auto recv = this_object.IsEmpty() ? isolate->GetCurrentContext()->Global() : this_object;
|
||||
auto result = Nan::Call(function, recv, (int)argc, const_cast<v8::Local<v8::Value>*>(arguments));
|
||||
|
||||
if (trycatch.HasCaught()) {
|
||||
throw node::Exception(isolate, trycatch.Exception());
|
||||
|
|
Loading…
Reference in New Issue