Commit a115491b authored by Ronan's avatar Ronan

fix(call-single-tester): avoid out of bounds when call stats type is TEXT in call_stats_updated

parent d2506c61
...@@ -109,35 +109,42 @@ static void rtcp_received(stats* counters, mblk_t *packet) { ...@@ -109,35 +109,42 @@ static void rtcp_received(stats* counters, mblk_t *packet) {
} }
void call_stats_updated(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *lstats) { void call_stats_updated(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *lstats) {
stats* counters = get_stats(lc); const int updated = _linphone_call_stats_get_updated(lstats);
stats *counters = get_stats(lc);
counters->number_of_LinphoneCallStatsUpdated++; counters->number_of_LinphoneCallStatsUpdated++;
if (_linphone_call_stats_get_updated(lstats) & LINPHONE_CALL_STATS_RECEIVED_RTCP_UPDATE) { if (updated & LINPHONE_CALL_STATS_RECEIVED_RTCP_UPDATE) {
counters->number_of_rtcp_received++; counters->number_of_rtcp_received++;
if (_linphone_call_stats_rtcp_received_via_mux(lstats)){ if (_linphone_call_stats_rtcp_received_via_mux(lstats)){
counters->number_of_rtcp_received_via_mux++; counters->number_of_rtcp_received_via_mux++;
} }
rtcp_received(counters, _linphone_call_stats_get_received_rtcp(lstats)); rtcp_received(counters, _linphone_call_stats_get_received_rtcp(lstats));
} }
if (_linphone_call_stats_get_updated(lstats) & LINPHONE_CALL_STATS_SENT_RTCP_UPDATE ) { if (updated & LINPHONE_CALL_STATS_SENT_RTCP_UPDATE ) {
counters->number_of_rtcp_sent++; counters->number_of_rtcp_sent++;
} }
if (_linphone_call_stats_get_updated(lstats) & LINPHONE_CALL_STATS_PERIODICAL_UPDATE ) { if (updated & LINPHONE_CALL_STATS_PERIODICAL_UPDATE ) {
int tab_size = sizeof (counters->audio_download_bandwidth)/sizeof(int); const int tab_size = sizeof counters->audio_download_bandwidth / sizeof(int);
int index = (counters->current_bandwidth_index[linphone_call_stats_get_type(lstats)]++) % tab_size;
LinphoneCallStats *audio_stats, *video_stats; LinphoneCallStats *call_stats;
audio_stats = linphone_call_get_audio_stats(call); int index;
video_stats = linphone_call_get_video_stats(call);
if (linphone_call_stats_get_type(lstats) == LINPHONE_CALL_STATS_AUDIO) { int type = linphone_call_stats_get_type(lstats);
counters->audio_download_bandwidth[index] = (int)linphone_call_stats_get_download_bandwidth(audio_stats); if (type != LINPHONE_CALL_STATS_AUDIO && type != LINPHONE_CALL_STATS_VIDEO)
counters->audio_upload_bandwidth[index] = (int)linphone_call_stats_get_upload_bandwidth(audio_stats); return; // Avoid out of bounds if type is TEXT.
index = (counters->current_bandwidth_index[type]++) % tab_size;
if (type == LINPHONE_CALL_STATS_AUDIO) {
call_stats = linphone_call_get_audio_stats(call);
counters->audio_download_bandwidth[index] = (int)linphone_call_stats_get_download_bandwidth(call_stats);
counters->audio_upload_bandwidth[index] = (int)linphone_call_stats_get_upload_bandwidth(call_stats);
} else { } else {
counters->video_download_bandwidth[index] = (int)linphone_call_stats_get_download_bandwidth(video_stats); call_stats = linphone_call_get_video_stats(call);
counters->video_upload_bandwidth[index] = (int)linphone_call_stats_get_upload_bandwidth(video_stats); counters->video_download_bandwidth[index] = (int)linphone_call_stats_get_download_bandwidth(call_stats);
counters->video_upload_bandwidth[index] = (int)linphone_call_stats_get_upload_bandwidth(call_stats);
} }
linphone_call_stats_unref(audio_stats); linphone_call_stats_unref(call_stats);
linphone_call_stats_unref(video_stats);
} }
} }
void linphone_call_encryption_changed(LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token) { void linphone_call_encryption_changed(LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment