From d53a2f4f054bcf0649bfa44b3d32c64f1828af98 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 19 Apr 2017 12:05:05 +0200 Subject: [PATCH] Fix crashes related to LinphoneVideoDefinition. --- coreapi/call_params.c | 8 +++++--- coreapi/linphonecall.c | 6 +++--- coreapi/linphonecore.c | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/coreapi/call_params.c b/coreapi/call_params.c index 8715ed049..b1bbf7d20 100644 --- a/coreapi/call_params.c +++ b/coreapi/call_params.c @@ -325,8 +325,6 @@ LinphoneCallParams * linphone_call_params_ref(LinphoneCallParams *cp) { } void linphone_call_params_unref(LinphoneCallParams *cp) { - if (cp->sent_vdef != NULL) linphone_video_definition_unref(cp->sent_vdef); - if (cp->recv_vdef != NULL) linphone_video_definition_unref(cp->recv_vdef); belle_sip_object_unref(cp); } @@ -358,6 +356,8 @@ static void _linphone_call_params_uninit(LinphoneCallParams *cp){ if (cp->custom_sdp_media_attributes[i]) sal_custom_sdp_attribute_free(cp->custom_sdp_media_attributes[i]); } if (cp->session_name) ms_free(cp->session_name); + if (cp->sent_vdef != NULL) linphone_video_definition_unref(cp->sent_vdef); + if (cp->recv_vdef != NULL) linphone_video_definition_unref(cp->recv_vdef); } static void _linphone_call_params_clone(LinphoneCallParams *dst, const LinphoneCallParams *src) { @@ -369,7 +369,9 @@ static void _linphone_call_params_clone(LinphoneCallParams *dst, const LinphoneC belle_sip_object_t tmp = dst->base; memcpy(dst, src, sizeof(LinphoneCallParams)); dst->base = tmp; - + + if (src->sent_vdef) dst->sent_vdef = linphone_video_definition_ref(src->sent_vdef); + if (src->recv_vdef) dst->recv_vdef = linphone_video_definition_ref(src->recv_vdef); if (src->record_file) dst->record_file=ms_strdup(src->record_file); if (src->session_name) dst->session_name=ms_strdup(src->session_name); /* diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index ce6e67302..3ce529cac 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1964,13 +1964,13 @@ const LinphoneCallParams * linphone_call_get_current_params(LinphoneCall *call){ #ifdef VIDEO_ENABLED VideoStream *vstream; #endif + MS_VIDEO_SIZE_ASSIGN(call->current_params->sent_vsize, UNKNOWN); + MS_VIDEO_SIZE_ASSIGN(call->current_params->recv_vsize, UNKNOWN); +#ifdef VIDEO_ENABLED if (call->current_params->sent_vdef != NULL) linphone_video_definition_unref(call->current_params->sent_vdef); call->current_params->sent_vdef = NULL; if (call->current_params->recv_vdef != NULL) linphone_video_definition_unref(call->current_params->recv_vdef); call->current_params->recv_vdef = NULL; - MS_VIDEO_SIZE_ASSIGN(call->current_params->sent_vsize, UNKNOWN); - MS_VIDEO_SIZE_ASSIGN(call->current_params->recv_vsize, UNKNOWN); -#ifdef VIDEO_ENABLED vstream = call->videostream; if (vstream != NULL) { call->current_params->sent_vsize = video_stream_get_sent_video_size(vstream); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index c549730e5..2742294c5 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -5846,7 +5846,8 @@ static void sound_config_uninit(LinphoneCore *lc) static void video_config_uninit(LinphoneCore *lc) { - lp_config_set_string(lc->config,"video","size",linphone_video_definition_get_name(linphone_core_get_preferred_video_definition(lc))); + const LinphoneVideoDefinition *vdef = linphone_core_get_preferred_video_definition(lc); + lp_config_set_string(lc->config,"video","size",vdef ? linphone_video_definition_get_name(vdef) : NULL); lp_config_set_int(lc->config,"video","display",lc->video_conf.display); lp_config_set_int(lc->config,"video","capture",lc->video_conf.capture); if (lc->video_conf.cams)