]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
prevent crash when calling mediaStats JSON function in certian circumstances
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 13 Jan 2015 21:49:43 +0000 (15:49 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 14 Jan 2015 03:49:41 +0000 (21:49 -0600)
src/mod/applications/mod_commands/mod_commands.c

index 75d8625af2cce2b81e20783dea5d3b7a297547b7..7215084977a3632f9420eb08fc84adb1833bad5b 100644 (file)
@@ -3173,8 +3173,13 @@ SWITCH_STANDARD_JSON_API(json_stats_function)
                audio_stats = switch_core_media_get_stats(tsession, SWITCH_MEDIA_TYPE_AUDIO, switch_core_session_get_pool(tsession));
                video_stats = switch_core_media_get_stats(tsession, SWITCH_MEDIA_TYPE_VIDEO, switch_core_session_get_pool(tsession));
                
-               jsonify_stats(reply, "audio", audio_stats);
-               jsonify_stats(reply, "video", video_stats);
+               if (audio_stats) {
+                       jsonify_stats(reply, "audio", audio_stats);
+               }
+               
+               if (video_stats) {
+                       jsonify_stats(reply, "video", video_stats);
+               }
                
                if (true_enough(cdata) && switch_ivr_generate_json_cdr(tsession, &jevent, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
                        cJSON_AddItemToObject(reply, "channelData", jevent);