mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-19 20:18:09 +00:00
fix potential memory leak of stun server resolver context
This commit is contained in:
parent
450823d634
commit
3dcb23ac8d
3 changed files with 15 additions and 8 deletions
|
|
@ -1198,11 +1198,10 @@ SalResolverContext * sal_resolve(Sal *sal, const char *service, const char *tran
|
|||
return (SalResolverContext *)belle_sip_stack_resolve(sal->stack, service, transport, name, port, family, (belle_sip_resolver_callback_t)cb, data);
|
||||
}
|
||||
|
||||
/*
|
||||
void sal_resolve_cancel(Sal *sal, SalResolverContext* ctx){
|
||||
belle_sip_stack_resolve_cancel(sal->stack,ctx);
|
||||
void sal_resolve_cancel(SalResolverContext* ctx){
|
||||
belle_sip_resolver_context_cancel((belle_sip_resolver_context_t*)ctx);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void sal_enable_unconditional_answer(Sal *sal,int value) {
|
||||
belle_sip_provider_enable_unconditional_answer(sal->prov,value);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ static void linphone_nat_policy_destroy(LinphoneNatPolicy *policy) {
|
|||
if (policy->stun_server) belle_sip_free(policy->stun_server);
|
||||
if (policy->stun_server_username) belle_sip_free(policy->stun_server_username);
|
||||
if (policy->stun_addrinfo) bctbx_freeaddrinfo(policy->stun_addrinfo);
|
||||
//if (policy->stun_resolver_context) sal_resolve_cancel(policy->stun_resolver_context);
|
||||
if (policy->stun_resolver_context) {
|
||||
sal_resolve_cancel(policy->stun_resolver_context);
|
||||
}
|
||||
}
|
||||
|
||||
static bool_t linphone_nat_policy_stun_server_activated(LinphoneNatPolicy *policy) {
|
||||
|
|
@ -213,7 +215,10 @@ static void stun_server_resolved(LinphoneNatPolicy *policy, const char *name, st
|
|||
ms_warning("Stun server resolution failed.");
|
||||
}
|
||||
policy->stun_addrinfo = addrinfo;
|
||||
policy->stun_resolver_context = NULL;
|
||||
if (policy->stun_resolver_context){
|
||||
sal_resolver_context_unref(policy->stun_resolver_context);
|
||||
policy->stun_resolver_context = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void linphone_nat_policy_resolve_stun_server(LinphoneNatPolicy *policy) {
|
||||
|
|
@ -229,6 +234,7 @@ void linphone_nat_policy_resolve_stun_server(LinphoneNatPolicy *policy) {
|
|||
int family = AF_INET;
|
||||
if (linphone_core_ipv6_enabled(policy->lc) == TRUE) family = AF_INET6;
|
||||
policy->stun_resolver_context = sal_resolve(policy->lc->sal, service, "udp", host, port, family, (SalResolverCallback)stun_server_resolved, policy);
|
||||
if (policy->stun_resolver_context) sal_resolver_context_ref(policy->stun_resolver_context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -831,11 +831,13 @@ void sal_get_default_local_ip(Sal *sal, int address_family, char *ip, size_t ipl
|
|||
|
||||
typedef void (*SalResolverCallback)(void *data, const char *name, struct addrinfo *ai_list);
|
||||
|
||||
typedef struct SalResolverContext SalResolverContext;
|
||||
|
||||
typedef struct SalResolverContext SalResolverContext;
|
||||
#define sal_resolver_context_ref(obj) belle_sip_object_ref(obj)
|
||||
#define sal_resolver_context_unref(obj) belle_sip_object_unref(obj)
|
||||
LINPHONE_PUBLIC SalResolverContext * sal_resolve_a(Sal* sal, const char *name, int port, int family, SalResolverCallback cb, void *data);
|
||||
LINPHONE_PUBLIC SalResolverContext * sal_resolve(Sal *sal, const char *service, const char *transport, const char *name, int port, int family, SalResolverCallback cb, void *data);
|
||||
//void sal_resolve_cancel(Sal *sal, SalResolverContext *ctx);
|
||||
void sal_resolve_cancel(SalResolverContext *ctx);
|
||||
|
||||
SalCustomHeader *sal_custom_header_append(SalCustomHeader *ch, const char *name, const char *value);
|
||||
const char *sal_custom_header_find(const SalCustomHeader *ch, const char *name);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue