Commit 9c396a9c authored by Simon Morlat's avatar Simon Morlat

Fix big crash in call logs because logs built from linphonerc were constructed...

Fix big crash in call logs because logs built from linphonerc were constructed using ms_new0(LinphoneCallLog,1).
parent c9c23c23
...@@ -104,13 +104,16 @@ void call_logs_read_from_config_file(LinphoneCore *lc){ ...@@ -104,13 +104,16 @@ void call_logs_read_from_config_file(LinphoneCore *lc){
for(i=0;;++i){ for(i=0;;++i){
snprintf(logsection,sizeof(logsection),"call_log_%i",i); snprintf(logsection,sizeof(logsection),"call_log_%i",i);
if (lp_config_has_section(cfg,logsection)){ if (lp_config_has_section(cfg,logsection)){
LinphoneCallLog *cl=ms_new0(LinphoneCallLog,1); LinphoneCallLog *cl;
cl->dir=lp_config_get_int(cfg,logsection,"dir",0); LinphoneAddress *from=NULL,*to=NULL;
cl->status=lp_config_get_int(cfg,logsection,"status",0);
tmp=lp_config_get_string(cfg,logsection,"from",NULL); tmp=lp_config_get_string(cfg,logsection,"from",NULL);
if (tmp) cl->from=linphone_address_new(tmp); if (tmp) from=linphone_address_new(tmp);
tmp=lp_config_get_string(cfg,logsection,"to",NULL); tmp=lp_config_get_string(cfg,logsection,"to",NULL);
if (tmp) cl->to=linphone_address_new(tmp); if (tmp) to=linphone_address_new(tmp);
if (!from || !to)
continue;
cl=linphone_call_log_new(lp_config_get_int(cfg,logsection,"dir",0),from,to);
cl->status=lp_config_get_int(cfg,logsection,"status",0);
sec=lp_config_get_int64(cfg,logsection,"start_date_time",0); sec=lp_config_get_int64(cfg,logsection,"start_date_time",0);
if (sec) { if (sec) {
/*new call log format with date expressed in seconds */ /*new call log format with date expressed in seconds */
...@@ -266,9 +269,9 @@ static void _linphone_call_log_destroy(LinphoneCallLog *cl){ ...@@ -266,9 +269,9 @@ static void _linphone_call_log_destroy(LinphoneCallLog *cl){
if (cl->reporting.reports[LINPHONE_CALL_STATS_VIDEO]!=NULL) linphone_reporting_destroy(cl->reporting.reports[LINPHONE_CALL_STATS_VIDEO]); if (cl->reporting.reports[LINPHONE_CALL_STATS_VIDEO]!=NULL) linphone_reporting_destroy(cl->reporting.reports[LINPHONE_CALL_STATS_VIDEO]);
} }
LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneAddress *from, LinphoneAddress *to){ LinphoneCallLog * linphone_call_log_new(LinphoneCallDir dir, LinphoneAddress *from, LinphoneAddress *to){
LinphoneCallLog *cl=belle_sip_object_new(LinphoneCallLog); LinphoneCallLog *cl=belle_sip_object_new(LinphoneCallLog);
cl->dir=call->dir; cl->dir=dir;
cl->start_date_time=time(NULL); cl->start_date_time=time(NULL);
set_call_log_date(cl,cl->start_date_time); set_call_log_date(cl,cl->start_date_time);
cl->from=from; cl->from=from;
......
...@@ -573,8 +573,7 @@ static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from, ...@@ -573,8 +573,7 @@ static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from,
call->state=LinphoneCallIdle; call->state=LinphoneCallIdle;
call->transfer_state = LinphoneCallIdle; call->transfer_state = LinphoneCallIdle;
call->media_start_time=0; call->media_start_time=0;
call->log=linphone_call_log_new(call, from, to); call->log=linphone_call_log_new(call->dir, from, to);
call->owns_call_log=TRUE;
call->camera_enabled=TRUE; call->camera_enabled=TRUE;
call->current_params.media_encryption=LinphoneMediaEncryptionNone; call->current_params.media_encryption=LinphoneMediaEncryptionNone;
...@@ -864,7 +863,6 @@ static void linphone_call_set_terminated(LinphoneCall *call){ ...@@ -864,7 +863,6 @@ static void linphone_call_set_terminated(LinphoneCall *call){
linphone_core_update_allocated_audio_bandwidth(lc); linphone_core_update_allocated_audio_bandwidth(lc);
linphone_call_stats_uninit(&call->stats[0]); linphone_call_stats_uninit(&call->stats[0]);
linphone_call_stats_uninit(&call->stats[1]); linphone_call_stats_uninit(&call->stats[1]);
call->owns_call_log=FALSE;
linphone_call_log_completed(call); linphone_call_log_completed(call);
...@@ -1041,8 +1039,8 @@ static void linphone_call_destroy(LinphoneCall *obj) ...@@ -1041,8 +1039,8 @@ static void linphone_call_destroy(LinphoneCall *obj)
if (obj->transfer_target){ if (obj->transfer_target){
linphone_call_unref(obj->transfer_target); linphone_call_unref(obj->transfer_target);
} }
if (obj->owns_call_log) if (obj->log)
linphone_call_log_destroy(obj->log); linphone_call_log_unref(obj->log);
if (obj->auth_token) { if (obj->auth_token) {
ms_free(obj->auth_token); ms_free(obj->auth_token);
} }
...@@ -3114,7 +3112,7 @@ void linphone_call_log_completed(LinphoneCall *call){ ...@@ -3114,7 +3112,7 @@ void linphone_call_log_completed(LinphoneCall *call){
lc->vtable.display_status(lc,info); lc->vtable.display_status(lc,info);
ms_free(info); ms_free(info);
} }
lc->call_logs=ms_list_prepend(lc->call_logs,(void *)call->log); lc->call_logs=ms_list_prepend(lc->call_logs,linphone_call_log_ref(call->log));
if (ms_list_size(lc->call_logs)>lc->max_call_logs){ if (ms_list_size(lc->call_logs)>lc->max_call_logs){
MSList *elem,*prevelem=NULL; MSList *elem,*prevelem=NULL;
/*find the last element*/ /*find the last element*/
...@@ -3122,7 +3120,7 @@ void linphone_call_log_completed(LinphoneCall *call){ ...@@ -3122,7 +3120,7 @@ void linphone_call_log_completed(LinphoneCall *call){
prevelem=elem; prevelem=elem;
} }
elem=prevelem; elem=prevelem;
linphone_call_log_destroy((LinphoneCallLog*)elem->data); linphone_call_log_unref((LinphoneCallLog*)elem->data);
lc->call_logs=ms_list_remove_link(lc->call_logs,elem); lc->call_logs=ms_list_remove_link(lc->call_logs,elem);
} }
if (lc->vtable.call_log_updated!=NULL){ if (lc->vtable.call_log_updated!=NULL){
...@@ -3186,7 +3184,7 @@ void linphone_call_zoom_video(LinphoneCall* call, float zoom_factor, float* cx, ...@@ -3186,7 +3184,7 @@ void linphone_call_zoom_video(LinphoneCall* call, float zoom_factor, float* cx,
zoom[0] = zoom_factor; zoom[0] = zoom_factor;
zoom[1] = *cx; zoom[1] = *cx;
zoom[2] = *cy; zoom[2] = *cy;
ms_filter_call_method(vstream->output, MS_VIDEO_DISPLAY_ZOOM, &zoom); ms_filter_call_method(vstream->output, MS_VIDEO_DISPLAY_ZOOM, &zoom);
}else ms_warning("Could not apply zoom: video output wasn't activated."); }else ms_warning("Could not apply zoom: video output wasn't activated.");
} }
......
...@@ -4497,7 +4497,7 @@ const MSList * linphone_core_get_call_logs(LinphoneCore *lc){ ...@@ -4497,7 +4497,7 @@ const MSList * linphone_core_get_call_logs(LinphoneCore *lc){
void linphone_core_clear_call_logs(LinphoneCore *lc){ void linphone_core_clear_call_logs(LinphoneCore *lc){
lc->missed_calls=0; lc->missed_calls=0;
ms_list_for_each(lc->call_logs,(void (*)(void*))linphone_call_log_destroy); ms_list_for_each(lc->call_logs,(void (*)(void*))linphone_call_log_unref);
lc->call_logs=ms_list_free(lc->call_logs); lc->call_logs=ms_list_free(lc->call_logs);
call_logs_write_to_config_file(lc); call_logs_write_to_config_file(lc);
} }
...@@ -4513,7 +4513,7 @@ void linphone_core_reset_missed_calls_count(LinphoneCore *lc) { ...@@ -4513,7 +4513,7 @@ void linphone_core_reset_missed_calls_count(LinphoneCore *lc) {
void linphone_core_remove_call_log(LinphoneCore *lc, LinphoneCallLog *cl){ void linphone_core_remove_call_log(LinphoneCore *lc, LinphoneCallLog *cl){
lc->call_logs = ms_list_remove(lc->call_logs, cl); lc->call_logs = ms_list_remove(lc->call_logs, cl);
call_logs_write_to_config_file(lc); call_logs_write_to_config_file(lc);
linphone_call_log_destroy(cl); linphone_call_log_unref(cl);
} }
...@@ -5735,7 +5735,7 @@ static void linphone_core_uninit(LinphoneCore *lc) ...@@ -5735,7 +5735,7 @@ static void linphone_core_uninit(LinphoneCore *lc)
lp_config_destroy(lc->config); lp_config_destroy(lc->config);
lc->config = NULL; /* Mark the config as NULL to block further calls */ lc->config = NULL; /* Mark the config as NULL to block further calls */
ms_list_for_each(lc->call_logs,(void (*)(void*))linphone_call_log_destroy); ms_list_for_each(lc->call_logs,(void (*)(void*))linphone_call_log_unref);
lc->call_logs=ms_list_free(lc->call_logs); lc->call_logs=ms_list_free(lc->call_logs);
ms_list_for_each(lc->last_recv_msg_ids,ms_free); ms_list_for_each(lc->last_recv_msg_ids,ms_free);
......
...@@ -238,15 +238,14 @@ struct _LinphoneCall ...@@ -238,15 +238,14 @@ struct _LinphoneCall
bool_t all_muted; /*this flag is set during early medias*/ bool_t all_muted; /*this flag is set during early medias*/
bool_t playing_ringbacktone; bool_t playing_ringbacktone;
bool_t owns_call_log;
bool_t ringing_beep; /* whether this call is ringing through an already existent current call*/ bool_t ringing_beep; /* whether this call is ringing through an already existent current call*/
bool_t auth_token_verified; bool_t auth_token_verified;
bool_t defer_update; bool_t defer_update;
bool_t was_automatically_paused; bool_t was_automatically_paused;
bool_t ping_replied; bool_t ping_replied;
bool_t record_active; bool_t record_active;
bool_t paused_by_app; bool_t paused_by_app;
}; };
...@@ -259,7 +258,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const ...@@ -259,7 +258,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const
void linphone_call_set_contact_op(LinphoneCall* call); void linphone_call_set_contact_op(LinphoneCall* call);
void linphone_call_set_compatible_incoming_call_parameters(LinphoneCall *call, const SalMediaDescription *md); void linphone_call_set_compatible_incoming_call_parameters(LinphoneCall *call, const SalMediaDescription *md);
/* private: */ /* private: */
LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneAddress *local, LinphoneAddress * remote); LinphoneCallLog * linphone_call_log_new(LinphoneCallDir dir, LinphoneAddress *local, LinphoneAddress * remote);
void linphone_call_log_completed(LinphoneCall *call); void linphone_call_log_completed(LinphoneCall *call);
void linphone_call_log_destroy(LinphoneCallLog *cl); void linphone_call_log_destroy(LinphoneCallLog *cl);
void linphone_call_set_transfer_state(LinphoneCall* call, LinphoneCallState state); void linphone_call_set_transfer_state(LinphoneCall* call, LinphoneCallState state);
......
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