]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11552: [mod_v8] Crash when accessing props of dead session
authorChristian Schmidt <cs@firmafon.dk>
Wed, 5 Dec 2018 21:10:25 +0000 (22:10 +0100)
committerChristian Schmidt <cs@firmafon.dk>
Wed, 5 Dec 2018 21:10:25 +0000 (22:10 +0100)
src/mod/languages/mod_v8/src/fssession.cpp

index a34406a493722a5fe37c1d99131faf27c287385e..c8a315ced0ac21dbb03081447d06fa8c00575837 100644 (file)
@@ -1530,11 +1530,23 @@ JS_SESSION_GET_PROPERTY_IMPL(GetProperty)
                        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)));
+               if (channel) {
+                       info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), switch_channel_get_name(channel)));
+               } else {
+                       info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), ""));
+               }
        } else if (!strcmp(prop, "uuid")) {
-               info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), switch_channel_get_uuid(channel)));
+               if (channel) {
+                       info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), switch_channel_get_uuid(channel)));
+               } else {
+                       info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), ""));
+               }
        } else if (!strcmp(prop, "state")) {
-               info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), switch_channel_state_name(switch_channel_get_state(channel))));
+               if (channel) {
+                       info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), switch_channel_state_name(switch_channel_get_state(channel))));
+               } else {
+                       info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), ""));
+               }
        } else if (!strcmp(prop, "dialplan")) {
                if (caller_profile) {
                        info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), caller_profile->dialplan));