diff --git a/src/c-wrapper/api/c-chat-message.cpp b/src/c-wrapper/api/c-chat-message.cpp index c5b4c45b4..4668066a6 100644 --- a/src/c-wrapper/api/c-chat-message.cpp +++ b/src/c-wrapper/api/c-chat-message.cpp @@ -46,7 +46,7 @@ L_DECLARE_C_OBJECT_IMPL_WITH_XTORS(ChatMessage, LinphoneAddress *to; // cache for shared_ptr
LinphoneChatMessageStateChangedCb message_state_changed_cb; void* message_state_changed_user_data; - mutable string contentTypeCache; + mutable char *contentTypeCache; ) static void _linphone_chat_message_constructor (LinphoneChatMessage *msg) { @@ -60,6 +60,8 @@ static void _linphone_chat_message_destructor (LinphoneChatMessage *msg) { linphone_address_unref(msg->from); if (msg->to) linphone_address_unref(msg->to); + if (msg->contentTypeCache) + ms_free(msg->contentTypeCache); } // ============================================================================= @@ -319,8 +321,11 @@ void * linphone_chat_message_get_message_state_changed_cb_user_data(LinphoneChat // ============================================================================= const char * linphone_chat_message_get_content_type(LinphoneChatMessage *msg) { - msg->contentTypeCache = L_GET_PRIVATE_FROM_C_OBJECT(msg)->getContentType().asString(); - return L_STRING_TO_C(msg->contentTypeCache); + if (msg->contentTypeCache) { + ms_free(msg->contentTypeCache); + } + msg->contentTypeCache = ms_strdup(L_STRING_TO_C(L_GET_PRIVATE_FROM_C_OBJECT(msg)->getContentType().asString())); + return msg->contentTypeCache; } void linphone_chat_message_set_content_type(LinphoneChatMessage *msg, const char *content_type) { diff --git a/src/chat/chat-room.cpp b/src/chat/chat-room.cpp index 150e19bf2..85a583f0f 100644 --- a/src/chat/chat-room.cpp +++ b/src/chat/chat-room.cpp @@ -551,6 +551,12 @@ void ChatRoom::compose () { shared_ptr