]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6290 --resolve
authorPeter Olsson <peter@olssononline.se>
Sat, 1 Mar 2014 09:02:45 +0000 (10:02 +0100)
committerPeter Olsson <peter@olssononline.se>
Sat, 1 Mar 2014 09:03:56 +0000 (10:03 +0100)
src/mod/languages/mod_v8/mod_v8.cpp
src/mod/languages/mod_v8/src/fscoredb.cpp
src/mod/languages/mod_v8/src/fscurl.cpp
src/mod/languages/mod_v8/src/fssession.cpp
src/mod/languages/mod_v8/src/fsteletone.cpp

index 7d1cdefaf55057d21432730535db4bdb8794bf3b..c59a1746fb1326c15a7bc02ead955546f5640cc3 100644 (file)
@@ -179,11 +179,6 @@ static switch_status_t v8_mod_load_file(const char *filename)
 
        v8_mod_init = (v8_mod_init_t) (intptr_t) function_handle;
 
-       if (v8_mod_init == NULL) {
-               err = "Cannot Load";
-               goto err;
-       }
-
        if (v8_mod_init(&module_interface) != SWITCH_STATUS_SUCCESS) {
                err = "Module load routine returned an error";
                goto err;
index 2cf15c0a2ab2b76bb733f326b64049acf848d6f3..a846eb8bbf4edb058c95fe0a0eb7c03abefb6c28 100644 (file)
@@ -101,13 +101,14 @@ void *FSCoreDB::Construct(const v8::FunctionCallbackInfo<Value>& info)
 int FSCoreDB::Callback(void *pArg, int argc, char **argv, char **columnNames)
 {
        FSCoreDB *dbo = static_cast<FSCoreDB *>(pArg);
-       HandleScope handle_scope(dbo->GetIsolate());
        int x = 0;
 
        if (!dbo) {
                return 0;
        }
 
+       HandleScope handle_scope(dbo->GetIsolate());
+
        if (dbo->_callback.IsEmpty()) {
                dbo->GetIsolate()->ThrowException(String::NewFromUtf8(dbo->GetIsolate(), "No callback specified"));
                return 0;
index 240f8d15817eac94282a5c628c99bc182bf3a3de..d81c9d9caa22613f2dabf70ffa7d41423f0dbef2 100644 (file)
@@ -60,7 +60,6 @@ string FSCURL::GetJSClassName()
 size_t FSCURL::FileCallback(void *ptr, size_t size, size_t nmemb, void *data)
 {
        FSCURL *obj = static_cast<FSCURL *>(data);
-       HandleScope handle_scope(obj->GetIsolate());
        register unsigned int realsize = (unsigned int) (size * nmemb);
        uint32_t argc = 0;
        Handle<Value> argv[4];
@@ -69,6 +68,7 @@ size_t FSCURL::FileCallback(void *ptr, size_t size, size_t nmemb, void *data)
                return 0;
        }
 
+       HandleScope handle_scope(obj->GetIsolate());
        Handle<Function> func;
        
        if (!obj->_function.IsEmpty()) {
index 9c03c8e7dc9b2b77834e44fe441f65448d0dc786..eeaef7894c6b1301adcf16fd9bad837c5e2d2455 100644 (file)
@@ -694,6 +694,10 @@ JS_SESSION_FUNCTION_IMPL(SayPhrase)
 
 bool FSSession::CheckHangupHook(FSSession *obj, bool *ret)
 {
+       if (!obj) {
+               return true;
+       }
+
        Isolate *isolate = obj->GetIsolate();
        HandleScope handle_scope(isolate);
        Handle<Value> argv[2];
@@ -701,7 +705,7 @@ bool FSSession::CheckHangupHook(FSSession *obj, bool *ret)
        bool res = true;
        string resp;
 
-       if (obj && !obj->_check_state && !obj->_on_hangup.IsEmpty() && (obj->_hook_state == CS_HANGUP || obj->_hook_state == CS_ROUTING)) {
+       if (!obj->_check_state && !obj->_on_hangup.IsEmpty() && (obj->_hook_state == CS_HANGUP || obj->_hook_state == CS_ROUTING)) {
                obj->_check_state++;
                argv[argc++] = Local<Object>::New(obj->GetOwner()->GetIsolate(), obj->GetJavaScriptObject());
 
@@ -1499,18 +1503,14 @@ JS_SESSION_GET_PROPERTY_IMPL(GetProperty)
        if (!strcmp(prop, "cause")) {
                if (channel) {
                        info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), switch_channel_cause2str(switch_channel_get_cause(channel))));
-               } else if (this) {
-                       info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), switch_channel_cause2str(this->_cause)));
                } else {
-                       info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), ""));
+                       info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), switch_channel_cause2str(this->_cause)));
                }
        } else if (!strcmp(prop, "causecode")) {
                if (channel) {
                        info.GetReturnValue().Set(Integer::New(info.GetIsolate(), switch_channel_get_cause(channel)));
-               } else if (this) {
-                       info.GetReturnValue().Set(Integer::New(info.GetIsolate(), this->_cause));
                } else {
-                       info.GetReturnValue().Set(Integer::New(info.GetIsolate(), 0));
+                       info.GetReturnValue().Set(Integer::New(info.GetIsolate(), this->_cause));
                }
        } else if (!strcmp(prop, "name")) {
                info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), switch_channel_get_name(channel)));
index 9b1f355d2a89300670206525385c01e54f504634..c77edd5db5c0a2900f4a7f229f9478bce0e80a4e 100644 (file)
@@ -304,7 +304,7 @@ JS_TELETONE_FUNCTION_IMPL(Generate)
                                        break;
                                }
                        }
-                       if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(_audio_buffer,
+                       if (!_audio_buffer || (write_frame.datalen = (uint32_t) switch_buffer_read_loop(_audio_buffer,
                                                                                                                                                  fdata, write_frame.codec->implementation->decoded_bytes_per_packet)) <= 0) {
                                break;
                        }