]> sjero.net Git - linphone/commitdiff
Add checks to prevent crashes.
authorGhislain MARY <ghislain.mary@belledonne-communications.com>
Thu, 22 Nov 2012 10:36:29 +0000 (11:36 +0100)
committerGhislain MARY <ghislain.mary@belledonne-communications.com>
Thu, 22 Nov 2012 10:36:29 +0000 (11:36 +0100)
The getReceiverInterarrivalJitter() function may be called before the
used audio codec is known in case of early media, so test that the
payload type is valid before using it.

coreapi/linphonecore_jni.cc

index 55041b17a88d3093b88be05e3c70bb62944c65d0..03d5c0df0a8402637187581a0b27f13e95fd15f1 100644 (file)
@@ -1372,6 +1372,8 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarr
                pt = linphone_call_params_get_used_audio_codec(params);
        else
                pt = linphone_call_params_get_used_video_codec(params);
+       if (!pt || (pt->clock_rate == 0))
+               return (jfloat)0.0;
        return (jfloat)((float)report_block_get_interarrival_jitter(srb) / (float)pt->clock_rate);
 }
 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
@@ -1399,6 +1401,8 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverIntera
                pt = linphone_call_params_get_used_audio_codec(params);
        else
                pt = linphone_call_params_get_used_video_codec(params);
+       if (!pt || (pt->clock_rate == 0))
+               return (jfloat)0.0;
        return (jfloat)((float)report_block_get_interarrival_jitter(rrb) / (float)pt->clock_rate);
 }
 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getRoundTripDelay(JNIEnv *env, jobject thiz, jlong stats_ptr) {