Fix accessing empty vector in V8FunctionInvoker
This commit is contained in:
parent
4b46eca329
commit
0ee2ab8a6e
1 changed files with 6 additions and 4 deletions
|
@ -56,7 +56,8 @@ struct V8FunctionInvoker<v8::Local<v8::Value>(ArgTypes...)> {
|
|||
v8::Local<v8::Context> context = holder->CreationContext();
|
||||
v8::Context::Scope context_scope(context);
|
||||
std::vector<v8::Local<v8::Value>> args { ConvertToV8(isolate, raw)... };
|
||||
v8::Local<v8::Value> ret(holder->Call(holder, args.size(), &args.front()));
|
||||
v8::Local<v8::Value> ret(holder->Call(
|
||||
holder, args.size(), args.empty() ? nullptr : &args.front()));
|
||||
return handle_scope.Escape(ret);
|
||||
}
|
||||
};
|
||||
|
@ -76,7 +77,8 @@ struct V8FunctionInvoker<void(ArgTypes...)> {
|
|||
v8::Local<v8::Context> context = holder->CreationContext();
|
||||
v8::Context::Scope context_scope(context);
|
||||
std::vector<v8::Local<v8::Value>> args { ConvertToV8(isolate, raw)... };
|
||||
holder->Call(holder, args.size(), &args.front());
|
||||
holder->Call(
|
||||
holder, args.size(), args.empty() ? nullptr : &args.front());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -97,8 +99,8 @@ struct V8FunctionInvoker<ReturnType(ArgTypes...)> {
|
|||
v8::Context::Scope context_scope(context);
|
||||
std::vector<v8::Local<v8::Value>> args { ConvertToV8(isolate, raw)... };
|
||||
v8::Local<v8::Value> result;
|
||||
auto maybe_result =
|
||||
holder->Call(context, holder, args.size(), &args.front());
|
||||
auto maybe_result = holder->Call(
|
||||
context, holder, args.size(), args.empty() ? nullptr : &args.front());
|
||||
if (maybe_result.ToLocal(&result))
|
||||
Converter<ReturnType>::FromV8(isolate, result, &ret);
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue