From 32b0ff04a864ebd7ff4cc0a7fdeb9f5c23c2cd96 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 2 Aug 2018 10:53:06 +0200 Subject: [PATCH] Fix bad cast of SalAddress into a LinphoneAddress in linphone_proxy_config_get_service_route(). --- coreapi/private_structs.h | 1 + coreapi/proxy.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/coreapi/private_structs.h b/coreapi/private_structs.h index f532cbcf9..8fef104f2 100644 --- a/coreapi/private_structs.h +++ b/coreapi/private_structs.h @@ -89,6 +89,7 @@ struct _LinphoneProxyConfig char *reg_identity; LinphoneAddress* identity_address; LinphoneAddress *contact_address; + LinphoneAddress *service_route; LinphoneAddress *contact_address_without_params; bctbx_list_t *reg_routes; char *quality_reporting_collector; diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 11972d9d1..00f4a2b1d 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -265,6 +265,7 @@ void _linphone_proxy_config_destroy(LinphoneProxyConfig *cfg){ linphone_error_info_unref(cfg->ei); } + if (cfg->service_route) linphone_address_unref(cfg->service_route); if (cfg->contact_address) linphone_address_unref(cfg->contact_address); if (cfg->contact_address_without_params) linphone_address_unref(cfg->contact_address_without_params); @@ -1416,8 +1417,22 @@ const LinphoneErrorInfo *linphone_proxy_config_get_error_info(const LinphoneProx } const LinphoneAddress* linphone_proxy_config_get_service_route(const LinphoneProxyConfig* cfg) { - return cfg->op?(const LinphoneAddress*) cfg->op->getServiceRoute():NULL; + if (!cfg->op) + return NULL; + const SalAddress *salAddr = cfg->op->getServiceRoute(); + if (!salAddr) + return NULL; + if (cfg->service_route) + L_GET_PRIVATE_FROM_C_OBJECT(cfg->service_route)->setInternalAddress(const_cast(salAddr)); + else { + char *buf = sal_address_as_string(salAddr); + const_cast(cfg)->service_route = linphone_address_new(buf); + ms_free(buf); + } + + return cfg->service_route; } + const char* linphone_proxy_config_get_transport(const LinphoneProxyConfig *cfg) { const char* addr=NULL; const char* ret="udp"; /*default value*/