Commit 0d5af07a authored by Simon Morlat's avatar Simon Morlat

fix memory leaks

parent 10d1411f
......@@ -97,14 +97,13 @@ void sal_disable_logs() {
void sal_add_pending_auth(Sal *sal, SalOp *op){
if (ms_list_find(sal->pending_auths,op)==NULL){
sal->pending_auths=ms_list_append(sal->pending_auths,sal_op_ref(op));
sal->pending_auths=ms_list_append(sal->pending_auths,op);
}
}
void sal_remove_pending_auth(Sal *sal, SalOp *op){
if (ms_list_find(sal->pending_auths,op)){
sal->pending_auths=ms_list_remove(sal->pending_auths,op);
sal_op_unref(op);
}
}
......@@ -157,7 +156,10 @@ void sal_process_authentication(SalOp *op) {
}
}
/*always store auth info, for case of wrong credential*/
if (op->auth_info) sal_auth_info_delete(op->auth_info);
if (op->auth_info) {
sal_auth_info_delete(op->auth_info);
op->auth_info=NULL;
}
if (auth_list){
auth_event=(belle_sip_auth_event_t*)(auth_list->data);
op->auth_info=sal_auth_info_create(auth_event);
......
......@@ -167,6 +167,7 @@ static void cancelling_invite(SalOp* op ){
sal_op_send_request(op,cancel);
op->state=SalOpStateTerminating;
}
static int vfu_retry (void *user_data, unsigned int events) {
SalOp *op=(SalOp *)user_data;
sal_call_send_vfu_request(op);
......
......@@ -44,8 +44,8 @@ void sal_op_release(SalOp *op){
void sal_op_release_impl(SalOp *op){
ms_message("Destroying op [%p] of type [%s]",op,sal_op_type_to_string(op->type));
if (op->pending_auth_transaction) belle_sip_object_unref(op->pending_auth_transaction);
sal_remove_pending_auth(op->base.root,op);
if (op->auth_info) {
sal_remove_pending_auth(op->base.root,op);
sal_auth_info_delete(op->auth_info);
}
if (op->sdp_answer) belle_sip_object_unref(op->sdp_answer);
......
......@@ -817,7 +817,11 @@ static void call_released(SalOp *op){
LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
if (call!=NULL){
linphone_call_set_state(call,LinphoneCallReleased,"Call released");
}else ms_error("call_released() for already destroyed call ?");
}else{
/*we can arrive here when the core manages call at Sal level without creating a LinphoneCall object. Typicially:
* - when declining an incoming call with busy because maximum number of calls is reached.
*/
}
}
static void auth_failure(SalOp *op, SalAuthInfo* info) {
......
......@@ -79,12 +79,15 @@ static LinphoneEvent *linphone_event_new_with_op_base(LinphoneCore *lc, SalOp *o
lev->is_out_of_dialog_op=is_out_of_dialog;
return lev;
}
LinphoneEvent *linphone_event_new_with_op(LinphoneCore *lc, SalOp *op, LinphoneSubscriptionDir dir, const char *name) {
return linphone_event_new_with_op_base(lc,op,dir,name,FALSE);
}
LinphoneEvent *linphone_event_new_with_out_of_dialog_op(LinphoneCore *lc, SalOp *op, LinphoneSubscriptionDir dir, const char *name) {
return linphone_event_new_with_op_base(lc,op,dir,name,TRUE);
}
void linphone_event_set_state(LinphoneEvent *lev, LinphoneSubscriptionState state){
LinphoneCore *lc=lev->lc;
if (lev->subscription_state!=state){
......@@ -107,9 +110,22 @@ void linphone_event_set_publish_state(LinphoneEvent *lev, LinphonePublishState s
if (lc->vtable.publish_state_changed){
lc->vtable.publish_state_changed(lev->lc,lev,state);
}
if (state==LinphonePublishCleared){
linphone_event_unref(lev);
switch(state){
case LinphonePublishCleared:
linphone_event_unref(lev);
break;
case LinphonePublishOk:
case LinphonePublishError:
if (lev->expires==-1)
linphone_event_unref(lev);
break;
case LinphonePublishNone:
case LinphonePublishProgress:
case LinphonePublishExpiring:
/*nothing special to do*/
break;
}
}
}
......
......@@ -246,14 +246,24 @@ static void end_call(LinphoneCoreManager *m1, LinphoneCoreManager *m2){
}
static void simple_call(void) {
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
belle_sip_object_enable_leak_detector(TRUE);
int begin=belle_sip_object_get_object_count();
int leaked_objects;
{
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
CU_ASSERT_TRUE(call(pauline,marie));
liblinphone_tester_check_rtcp(marie,pauline);
end_call(marie,pauline);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
CU_ASSERT_TRUE(call(pauline,marie));
liblinphone_tester_check_rtcp(marie,pauline);
end_call(marie,pauline);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
leaked_objects=belle_sip_object_get_object_count()-begin;
CU_ASSERT_TRUE(leaked_objects==0);
if (leaked_objects>0){
belle_sip_object_dump_active_objects();
}
}
static void call_with_specified_codec_bitrate(void) {
......
......@@ -28,7 +28,7 @@
#endif
static char* message_external_body_url;
static char* message_external_body_url=NULL;
void text_message_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from_address, const char *message) {
stats* counters = get_stats(lc);
......@@ -52,7 +52,8 @@ void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMess
linphone_chat_message_start_file_download(message);
} else if (linphone_chat_message_get_external_body_url(message)) {
counters->number_of_LinphoneMessageExtBodyReceived++;
CU_ASSERT_STRING_EQUAL(linphone_chat_message_get_external_body_url(message),message_external_body_url);
if (message_external_body_url)
CU_ASSERT_STRING_EQUAL(linphone_chat_message_get_external_body_url(message),message_external_body_url);
}
}
......
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