diff --git a/src/c-wrapper/api/c-chat-room.cpp b/src/c-wrapper/api/c-chat-room.cpp index ad3447da1..0717bee48 100644 --- a/src/c-wrapper/api/c-chat-room.cpp +++ b/src/c-wrapper/api/c-chat-room.cpp @@ -101,7 +101,10 @@ const LinphoneAddress *linphone_chat_room_get_peer_address (LinphoneChatRoom *cr } LinphoneChatMessage *linphone_chat_room_create_message (LinphoneChatRoom *cr, const char *message) { - return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createMessage(L_C_TO_STRING(message))); + shared_ptr cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createMessage(L_C_TO_STRING(message)); + LinphoneChatMessage *object = L_INIT(ChatMessage); + L_SET_CPP_PTR_FROM_C_OBJECT(object, cppPtr); + return object; } LinphoneChatMessage *linphone_chat_room_create_message_2 (