fix memory leak with call logs for early failed calls, and possible double free in case of error reporting for ended calls

This commit is contained in:
Simon Morlat 2011-02-09 22:43:21 +01:00
parent 5e3917037f
commit aff1134b38
2 changed files with 14 additions and 0 deletions

View file

@ -145,6 +145,7 @@ static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from,
call->start_time=time(NULL);
call->media_start_time=0;
call->log=linphone_call_log_new(call, from, to);
call->owns_call_log=TRUE;
linphone_core_notify_all_friends(call->core,LinphoneStatusOnThePhone);
port_offset=find_port_offset (call->core);
if (port_offset==-1) return;
@ -241,8 +242,10 @@ static void linphone_call_set_terminated(LinphoneCall *call){
else status=LinphoneCallSuccess;
}
call->owns_call_log=FALSE;
linphone_call_log_completed(call->log,call, status);
if (call == lc->current_call){
ms_message("Resetting the current call");
lc->current_call=NULL;
@ -305,6 +308,13 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const
LinphoneCore *lc=call->core;
if (call->state!=cstate){
if (call->state==LinphoneCallEnd || call->state==LinphoneCallError){
if (cstate!=LinphoneCallReleased){
ms_warning("Spurious call state change from %s to %s, ignored.",linphone_call_state_to_string(call->state),
linphone_call_state_to_string(cstate));
return;
}
}
ms_message("Call %p: moving from state %s to %s",call,linphone_call_state_to_string(call->state),
linphone_call_state_to_string(cstate));
if (cstate!=LinphoneCallRefered){
@ -315,6 +325,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const
if (cstate==LinphoneCallEnd || cstate==LinphoneCallError){
linphone_call_set_terminated (call);
}
if (lc->vtable.call_state_changed)
lc->vtable.call_state_changed(lc,call,cstate,message);
if (cstate==LinphoneCallReleased){
@ -349,6 +360,8 @@ static void linphone_call_destroy(LinphoneCall *obj)
if (obj->refer_to){
ms_free(obj->refer_to);
}
if (obj->owns_call_log)
linphone_call_log_destroy(obj->log);
ms_free(obj);
}

View file

@ -98,6 +98,7 @@ struct _LinphoneCall
bool_t camera_active;
bool_t all_muted; /*this flag is set during early medias*/
bool_t playing_ringbacktone;
bool_t owns_call_log;
};