Quality reporting: fix unit test segfault in case of invalid mediastream pointer

This commit is contained in:
Gautier Pelloux-Prayer 2014-06-16 15:51:42 +02:00
parent de947f4403
commit d4f2c4a099
2 changed files with 8 additions and 12 deletions

View file

@ -28,14 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <math.h>
/***************************************************************************
* TODO / REMINDER LIST
***************************************************************************
- negative cum loss without duplications?
***************************************************************************
* END OF TODO / REMINDER LIST
****************************************************************************/
#define STR_REASSIGN(dest, src) {\
if (dest != NULL) \
ms_free(dest); \

View file

@ -26,11 +26,15 @@
#define __strstr(x, y) ((x==NULL)?NULL:strstr(x,y))
void on_report_send_mandatory(const LinphoneCall *call, int stream_type, const LinphoneContent *content){
const MediaStream * ms = ((stream_type == LINPHONE_CALL_STATS_AUDIO)?&call->audiostream->ms:&call->videostream->ms);
char * body = (char *)content->data;
char * remote_metrics_start = __strstr(body, "RemoteMetrics:");
reporting_session_report_t * report = call->log->reporting.reports[stream_type];
MediaStream * ms;
if (stream_type == LINPHONE_CALL_STATS_AUDIO){
ms = (MediaStream*)call->audiostream;
}else{
ms = (MediaStream*)call->videostream;
}
CU_ASSERT_TRUE(
__strstr(body, "VQIntervalReport\r\n") == body ||
__strstr(body, "VQSessionReport\r\n") == body ||
@ -66,7 +70,7 @@ void on_report_send_mandatory(const LinphoneCall *call, int stream_type, const L
CU_ASSERT_PTR_NOT_NULL(body=__strstr(body, "DialogID:"));
if (report->remote_metrics.rtcp_sr_count&&ms->rc!=NULL){
if (report->remote_metrics.rtcp_sr_count&&ms!=NULL&&ms->rc!=NULL){
CU_ASSERT_PTR_NOT_NULL(body=__strstr(body, "AdaptiveAlg:"));
}
}
@ -78,7 +82,7 @@ char * on_report_send_verify_metrics(const reporting_content_metrics_t *metrics,
CU_ASSERT_PTR_NOT_NULL(body=__strstr(body, "PacketLoss:"));
CU_ASSERT_PTR_NOT_NULL(body=__strstr(body, "QualityEst:"));
}
if (metrics->rtcp_sr_count){
if (metrics->rtcp_sr_count+metrics->rtcp_xr_count>0){
CU_ASSERT_PTR_NOT_NULL(body=__strstr(body, "Delay:"));
}