Merge pull request #1452 in FS/freeswitch from ~ANDYWOLK/freeswitch:bugfix/FS-10789-v8-segs-on-invalid-instruction to master

* commit 'db3e6ec32f2a0bc8212e7ebbbfb1830740aa61c1':
  FS-10789: [mod_v8] v8 segs on invalid instruction
This commit is contained in:
Seven Du 2017-12-05 11:01:05 +00:00
commit 1480362519
4 changed files with 17 additions and 3 deletions

View File

@ -86,6 +86,11 @@
<CodeAnalysisRuleSet>NativeMinimumRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<DisableSpecificWarnings>4100;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>

View File

@ -665,7 +665,12 @@ static int v8_parse_and_execute(switch_core_session_t *session, const char *inpu
// Compile the source code.
#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5
v8::ScriptCompiler::CompileOptions options = v8::ScriptCompiler::kNoCompileOptions;
Handle<v8::Script> v8_script = v8::ScriptCompiler::Compile(context, &source, options).ToLocalChecked();
Handle<v8::Script> v8_script;
v8::MaybeLocal<v8::Script> v8_script_check = v8::ScriptCompiler::Compile(context, &source, options);
if (!v8_script_check.IsEmpty()) {
v8_script = v8_script_check.ToLocalChecked();
}
//Handle<v8::Script> v8_script = v8::ScriptCompiler::Compile(context, source,/* String::NewFromUtf8(isolate, script_file),*/ v8::ScriptCompiler::kProduceCodeCache).ToLocalChecked();
//source->GetCachedData();
#else

View File

@ -253,7 +253,7 @@ JS_DBH_FUNCTION_IMPL(query)
if (err) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error %s\n", err);
switch_core_db_free(err);
switch_safe_free(err);
info.GetReturnValue().Set(false);
}
}

View File

@ -158,7 +158,11 @@ void JSBase::CreateInstance(const v8::FunctionCallbackInfo<Value>& args)
v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Local<v8::String> key = String::NewFromUtf8(isolate, "constructor_method");
v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, key);
Handle<External> ex = Handle<External>::Cast(args.Callee()->GetPrivate(context, privateKey).ToLocalChecked());
Handle<External> ex;
v8::MaybeLocal<v8::Value> hiddenValue = args.Callee()->GetPrivate(context, privateKey);
if (!hiddenValue.IsEmpty()) {
ex = Handle<External>::Cast(hiddenValue.ToLocalChecked());
}
#else
Handle<External> ex = Handle<External>::Cast(args.Callee()->GetHiddenValue(String::NewFromUtf8(args.GetIsolate(), "constructor_method")));
#endif