[hotfix] Fix js callback crash issue. 52/179252/2 accepted/tizen/unified/20180517.062345 submit/tizen/20180517.000019
authorYongGeol Jung <yg48.jung@samsung.com>
Wed, 16 May 2018 14:35:26 +0000 (07:35 -0700)
committerjaekuk lee <juku1999@samsung.com>
Wed, 16 May 2018 14:43:22 +0000 (14:43 +0000)
JS callback causes crash if current |context| of |isolate| is null. To prevent
this, make new |context| for |isolate|.

Change-Id: I212beb06dfe9dfab310b71d1dbb594c3abb3c4c9
Signed-off-by: YongGeol Jung <yg48.jung@samsung.com>
extensions/renderer/runtime_ipc_client.cc

index 6b96828..3835b32 100644 (file)
@@ -43,6 +43,13 @@ void RuntimeIPCClient::JSCallback::Call(v8::Isolate* isolate,
   if (!callback_.IsEmpty()) {
     v8::HandleScope handle_scope(isolate);
     v8::TryCatch try_catch(isolate);
+    v8::Local<v8::Context> context(isolate->GetCurrentContext());
+    if (context.IsEmpty()) {
+     // If there's no JavaScript on the stack, we have to make a new Context.
+      context = v8::Context::New(isolate);
+    }
+    v8::Context::Scope scope(context);
+
     v8::Handle<v8::Function> func =
         v8::Local<v8::Function>::New(isolate, callback_);
     func->Call(func, 1, args);