]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10789: [mod_v8] v8 segs on invalid instruction
authorAndrey Volk <andywolk@gmail.com>
Tue, 5 Dec 2017 10:56:40 +0000 (13:56 +0300)
committerAndrey Volk <andywolk@gmail.com>
Tue, 5 Dec 2017 10:56:40 +0000 (13:56 +0300)
src/mod/languages/mod_v8/mod_v8.2015.vcxproj
src/mod/languages/mod_v8/mod_v8.cpp
src/mod/languages/mod_v8/src/fsdbh.cpp
src/mod/languages/mod_v8/src/jsbase.cpp

index 8eeab47b18bb78b9bf2c434ec1e325a991a89c6c..dfdf26e0ec2d20ac080adc387b4924c6848ec01a 100644 (file)
     <CodeAnalysisRuleSet>NativeMinimumRules.ruleset</CodeAnalysisRuleSet>\r
     <RunCodeAnalysis>false</RunCodeAnalysis>\r
   </PropertyGroup>\r
+  <ItemDefinitionGroup>\r
+    <ClCompile>\r
+      <DisableSpecificWarnings>4100;%(DisableSpecificWarnings)</DisableSpecificWarnings>\r
+    </ClCompile>\r
+  </ItemDefinitionGroup>\r
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
     <ClCompile>\r
       <Optimization>Disabled</Optimization>\r
index bd3882d0d891e1c9a6038572d64b85db106b46ae..1a73db85bf76c1a2d0e112556888418443f0bc83 100644 (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
index 605df59b89870ad8563474fa15f3645e4c97eb70..59bd3b8128ddb48d8aea09fdbd388c80d9e58158 100644 (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);
                }
        }
index 12d65b8996e8ae34d2f6744f7ae5d2dad4b5c49b..4fd320f4397af15263003347d35045c2e36e411c 100644 (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