diff --git a/coreapi/call_log.c b/coreapi/call_log.c
index f228a90afb861428f3b31554229927231ea4a255..a9eabde8e761cff529cdabcbe99a6882229c28ca 100644
--- a/coreapi/call_log.c
+++ b/coreapi/call_log.c
@@ -188,6 +188,11 @@ const char *linphone_call_log_get_call_id(const LinphoneCallLog *cl){
 	return cl->call_id;
 }
 
+void linphone_call_log_set_call_id(LinphoneCallLog *cl, const char *call_id) {
+	if (cl->call_id) bctbx_free(cl->call_id);
+	cl->call_id = call_id ? bctbx_strdup(call_id) : NULL;
+}
+
 LinphoneCallDir linphone_call_log_get_dir(const LinphoneCallLog *cl){
 	return cl->dir;
 }
diff --git a/coreapi/private_functions.h b/coreapi/private_functions.h
index 8b94b8ff0c31332babc294afce3b27f0c4b818f4..4040e61c08019445b5da1d1bc74772623090d77c 100644
--- a/coreapi/private_functions.h
+++ b/coreapi/private_functions.h
@@ -55,6 +55,7 @@ void linphone_call_notify_next_video_frame_decoded(LinphoneCall *call);
 LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to, const LinphoneCallParams *params, LinphoneProxyConfig *cfg);
 LinphoneCall * linphone_call_new_incoming(struct _LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to, LinphonePrivate::SalCallOp *op);
 LINPHONE_PUBLIC LinphoneCallLog *linphone_call_log_new(LinphoneCallDir dir, LinphoneAddress *from, LinphoneAddress * to);
+void linphone_call_log_set_call_id(LinphoneCallLog *cl, const char *call_id);
 LinphonePlayer *linphone_call_build_player(LinphoneCall*call);
 
 LinphonePrivate::SalCallOp *linphone_call_get_op(const LinphoneCall *call);
diff --git a/src/conference/session/call-session.cpp b/src/conference/session/call-session.cpp
index 0ab0d82d08ee01e3ecc53058a12bf547734138cf..30af1cd3bc75b737882c8c0a0431aef308f413ae 100644
--- a/src/conference/session/call-session.cpp
+++ b/src/conference/session/call-session.cpp
@@ -959,7 +959,7 @@ void CallSession::configure (LinphoneCallDir direction, LinphoneProxyConfig *cfg
 				linphone_core_get_config(getCore()->getCCore()), "sip", "cnx_ip_to_0000_if_sendonly_enabled", 0
 			)
 		);
-		d->log->call_id = ms_strdup(op->getCallId().c_str()); /* Must be known at that time */
+		linphone_call_log_set_call_id(d->log, op->getCallId().c_str()); /* Must be known at that time */
 	}
 
 	if (direction == LinphoneCallOutgoing) {
@@ -1127,7 +1127,7 @@ int CallSession::startInvite (const Address *destination, const string &subject,
 			d->setState(CallSession::State::Error, "Call failed");
 		}
 	} else {
-		d->log->call_id = ms_strdup(d->op->getCallId().c_str()); /* Must be known at that time */
+		linphone_call_log_set_call_id(d->log, d->op->getCallId().c_str()); /* Must be known at that time */
 		d->setState(CallSession::State::OutgoingProgress, "Outgoing call in progress");
 	}
 	return result;