From 0ee2ab8a6e4e0200f5ef0fb709b04cdf2aaf7900 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 31 Jul 2017 16:47:14 +0900 Subject: [PATCH] Fix accessing empty vector in V8FunctionInvoker --- atom/common/native_mate_converters/callback.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/atom/common/native_mate_converters/callback.h b/atom/common/native_mate_converters/callback.h index 8073d00779ea..34c6e5d62de3 100644 --- a/atom/common/native_mate_converters/callback.h +++ b/atom/common/native_mate_converters/callback.h @@ -56,7 +56,8 @@ struct V8FunctionInvoker(ArgTypes...)> { v8::Local context = holder->CreationContext(); v8::Context::Scope context_scope(context); std::vector> args { ConvertToV8(isolate, raw)... }; - v8::Local ret(holder->Call(holder, args.size(), &args.front())); + v8::Local ret(holder->Call( + holder, args.size(), args.empty() ? nullptr : &args.front())); return handle_scope.Escape(ret); } }; @@ -76,7 +77,8 @@ struct V8FunctionInvoker { v8::Local context = holder->CreationContext(); v8::Context::Scope context_scope(context); std::vector> 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 { v8::Context::Scope context_scope(context); std::vector> args { ConvertToV8(isolate, raw)... }; v8::Local 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::FromV8(isolate, result, &ret); return ret;