From f17014999b5d20909dee05472818b0fa2704dd5d Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 23 May 2016 21:59:41 +0200 Subject: [PATCH] fix crash at linphone_core_destroy() when add_missing_audio_codecs or add_missing_video_codec is set to 0. --- coreapi/linphonecore.c | 44 ++++++++++++++++++++++++++++++++++-------- mediastreamer2 | 2 +- oRTP | 2 +- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 36de8b3d0..7ab2f4d05 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1264,6 +1264,38 @@ static MSList *add_missing_supported_codecs(LinphoneCore *lc, const MSList *defa return newlist; } +/* + * This function adds missing codecs, if required by configuration. + * This 'l' list is entirely destroyed and a new list is returned. + */ +static MSList *handle_missing_codecs(LinphoneCore *lc, const MSList *default_list, MSList *l, MSFormatType ft){ + const char *name = "unknown"; + int add_missing; + MSList *ret; + + switch(ft){ + case MSAudio: + name = "add_missing_audio_codecs"; + break; + case MSVideo: + name = "add_missing_video_codecs"; + break; + case MSText: + name = "add_missing_text_codecs"; + break; + case MSUnknownMedia: + break; + } + add_missing = lp_config_get_int(lc->config, "misc", name, 1); + if (add_missing){ + ret = add_missing_supported_codecs(lc, default_list, l); + }else{ + ret = ms_list_copy_with_data(l,(void *(*)(void*))payload_type_clone); + ms_list_free(l); + } + return ret; +} + static MSList *codec_append_if_new(MSList *l, PayloadType *pt){ MSList *elem; for (elem=l;elem!=NULL;elem=elem->next){ @@ -1275,8 +1307,7 @@ static MSList *codec_append_if_new(MSList *l, PayloadType *pt){ return l; } -static void codecs_config_read(LinphoneCore *lc) -{ +static void codecs_config_read(LinphoneCore *lc){ int i; PayloadType *pt; MSList *audio_codecs=NULL; @@ -1291,18 +1322,15 @@ static void codecs_config_read(LinphoneCore *lc) audio_codecs=codec_append_if_new(audio_codecs, pt); } } - if( lp_config_get_int(lc->config, "misc", "add_missing_audio_codecs", 1) == 1 ){ - audio_codecs=add_missing_supported_codecs(lc, lc->default_audio_codecs,audio_codecs); - } + audio_codecs = handle_missing_codecs(lc, lc->default_audio_codecs,audio_codecs, MSAudio); for (i=0;get_codec(lc,SalVideo,i,&pt);i++){ if (pt){ video_codecs=codec_append_if_new(video_codecs, pt); } } - if( lp_config_get_int(lc->config, "misc", "add_missing_video_codecs", 1) == 1 ){ - video_codecs=add_missing_supported_codecs(lc, lc->default_video_codecs,video_codecs); - } + + video_codecs = handle_missing_codecs(lc, lc->default_video_codecs, video_codecs, MSVideo); for (i=0;get_codec(lc,SalText,i,&pt);i++){ if (pt){ diff --git a/mediastreamer2 b/mediastreamer2 index 24d1f4323..fd9850039 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 24d1f43234e9dcf07f6c803d9aa94317fe44dbf0 +Subproject commit fd98500399f8105534696deb7f3196b7b213aedd diff --git a/oRTP b/oRTP index 5b1c601c7..d10bdd483 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 5b1c601c74c2b3e0d4ab247c08a7b2ef3fb00e85 +Subproject commit d10bdd4832efa9b3bd6ce99b71873ca33326e812