Commit a5af301c authored by Simon Morlat's avatar Simon Morlat
Browse files

fix memory leaks

parent 9a782d2d
......@@ -154,6 +154,9 @@ static void handle_sdp_from_response(SalOp* op,belle_sip_response_t* response) {
SalReason reason;
if (extract_sdp(BELLE_SIP_MESSAGE(response),&sdp,&reason)==0) {
if (sdp){
if (op->base.remote_media){
sal_media_description_unref(op->base.remote_media);
}
op->base.remote_media=sal_media_description_new();
sdp_to_media_description(sdp,op->base.remote_media);
if (op->base.local_media) sdp_process(op);
......
......@@ -37,6 +37,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2/mseventqueue.h"
#include "mediastreamer2/mssndcard.h"
static void linphone_call_stats_uninit(LinphoneCallStats *stats);
#ifdef VIDEO_ENABLED
static MSWebCam *get_nowebcam_device(){
return ms_web_cam_manager_get_cam(ms_web_cam_manager_get(),"StaticImage: Static picture");
......@@ -743,7 +745,8 @@ static void linphone_call_set_terminated(LinphoneCall *call){
linphone_call_delete_upnp_session(call);
linphone_call_delete_ice_session(call);
linphone_core_update_allocated_audio_bandwidth(lc);
linphone_call_stats_uninit(&call->stats[0]);
linphone_call_stats_uninit(&call->stats[1]);
call->owns_call_log=FALSE;
linphone_call_log_completed(call);
......@@ -2697,20 +2700,14 @@ static void report_bandwidth(LinphoneCall *call, MediaStream *as, MediaStream *v
}
static void linphone_core_disconnected(LinphoneCore *lc, LinphoneCall *call){
char temp[256];
char temp[256]={0};
char *from=NULL;
if(call)
from = linphone_call_get_remote_address_as_string(call);
if (from)
{
snprintf(temp,sizeof(temp),"Remote end %s seems to have disconnected, the call is going to be closed.",from);
ms_free(from);
}
else
{
snprintf(temp,sizeof(temp),"Remote end seems to have disconnected, the call is going to be closed.");
}
ms_message("On call [%p] %s",call,temp);
from = linphone_call_get_remote_address_as_string(call);
snprintf(temp,sizeof(temp)-1,"Remote end %s seems to have disconnected, the call is going to be closed.",from ? from : "");
if (from) ms_free(from);
ms_message("On call [%p]: %s",call,temp);
if (lc->vtable.display_warning!=NULL)
lc->vtable.display_warning(lc,temp);
linphone_core_terminate_call(lc,call);
......@@ -2818,6 +2815,17 @@ void linphone_call_stats_fill(LinphoneCallStats *stats, MediaStream *ms, OrtpEve
}
}
void linphone_call_stats_uninit(LinphoneCallStats *stats){
if (stats->received_rtcp) {
freemsg(stats->received_rtcp);
stats->received_rtcp=NULL;
}
if (stats->sent_rtcp){
freemsg(stats->sent_rtcp);
stats->sent_rtcp=NULL;
}
}
void linphone_call_notify_stats_updated(LinphoneCall *call, int stream_index){
LinphoneCallStats *stats=&call->stats[stream_index];
LinphoneCore *lc=call->core;
......@@ -2952,8 +2960,8 @@ void linphone_call_set_transfer_state(LinphoneCall* call, LinphoneCallState stat
if (state != call->transfer_state) {
LinphoneCore* lc = call->core;
ms_message("Transfer state for call [%p] changed from [%s] to [%s]",call
,linphone_call_state_to_string(call->transfer_state)
,linphone_call_state_to_string(state));
,linphone_call_state_to_string(call->transfer_state)
,linphone_call_state_to_string(state));
call->transfer_state = state;
if (lc->vtable.transfer_state_changed)
lc->vtable.transfer_state_changed(lc, call, state);
......
......@@ -5890,6 +5890,15 @@ static void linphone_core_uninit(LinphoneCore *lc)
}
#endif //BUILD_UPNP
if (lc->chatrooms){
MSList *cr=ms_list_copy(lc->chatrooms);
MSList *elem;
for(elem=cr;elem!=NULL;elem=elem->next){
linphone_chat_room_destroy((LinphoneChatRoom*)elem->data);
}
ms_list_free(cr);
}
if (lp_config_needs_commit(lc->config)) lp_config_sync(lc->config);
lp_config_destroy(lc->config);
lc->config = NULL; /* Mark the config as NULL to block further calls */
......
......@@ -49,10 +49,7 @@ bool_t linphone_proxy_config_address_equal(const LinphoneAddress *a, const Linph
if (linphone_address_weak_equal(a,b)) {
/*also check both transport and uri */
if (!(linphone_address_is_secure(a) ^ linphone_address_is_secure(b))) {
return linphone_address_get_transport(a) == linphone_address_get_transport(b);
} else
return FALSE; /*secure flag not equals*/
return linphone_address_is_secure(a) == linphone_address_is_secure(b) && linphone_address_get_transport(a) == linphone_address_get_transport(b);
} else
return FALSE; /*either username, domain or port ar not equals*/
......@@ -61,14 +58,21 @@ bool_t linphone_proxy_config_address_equal(const LinphoneAddress *a, const Linph
bool_t linphone_proxy_config_is_server_config_changed(const LinphoneProxyConfig* obj) {
LinphoneAddress *current_identity=obj->reg_identity?linphone_address_new(obj->reg_identity):NULL;
LinphoneAddress *current_proxy=obj->reg_proxy?linphone_address_new(obj->reg_proxy):NULL;
bool_t result=FALSE;
if (!linphone_proxy_config_address_equal(obj->saved_identity,current_identity)){
result=TRUE;
goto end;
}
if (!linphone_proxy_config_address_equal(obj->saved_proxy,current_proxy)){
result=TRUE;
goto end;
}
if (!linphone_proxy_config_address_equal(obj->saved_identity,current_identity))
return TRUE;
if (!linphone_proxy_config_address_equal(obj->saved_proxy,current_proxy))
return TRUE;
return FALSE;
end:
if (current_identity) linphone_address_destroy(current_identity);
if (current_proxy) linphone_address_destroy(current_proxy);
return result;
}
void linphone_proxy_config_write_all_to_config_file(LinphoneCore *lc){
......@@ -151,7 +155,7 @@ void linphone_proxy_config_destroy(LinphoneProxyConfig *obj){
if (obj->contact_params) ms_free(obj->contact_params);
if (obj->contact_uri_params) ms_free(obj->contact_uri_params);
if (obj->saved_proxy!=NULL) linphone_address_destroy(obj->saved_proxy);
if (obj->saved_identity!=NULL) ms_free(obj->saved_identity);
if (obj->saved_identity!=NULL) linphone_address_destroy(obj->saved_identity);
ms_free(obj);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment