diff --git a/coreapi/friend.c b/coreapi/friend.c index 1b73b77893df8190a5f53fa2aeb7c7fba77133de..25855f993cf9aaceb0bb947b95ae58a79086df77 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -1832,7 +1832,7 @@ static int create_friend(void *data, BCTBX_UNUSED(int argc), char **argv, BCTBX_ } linphone_friend_set_inc_subscribe_policy(lf, static_cast<LinphoneSubscribePolicy>(atoi(argv[3]))); linphone_friend_send_subscribe(lf, !!atoi(argv[4])); - linphone_friend_set_ref_key(lf, ms_strdup(argv[5])); + linphone_friend_set_ref_key(lf, argv[5]); lf->presence_received = !!atoi(argv[9]); lf->storage_id = storage_id; @@ -2127,7 +2127,7 @@ const char *linphone_friend_phone_number_to_sip_uri(LinphoneFriend *lf, const ch if (strcmp(lfpnsu->number, phone_number) == 0) { /*force sip uri computation because proxy config may have changed, specially, ccc could have been added * since last computation*/ - // free_phone_number_sip_uri(lfpnsu); + free_phone_number_sip_uri(lfpnsu); if (lf->phone_number_sip_uri_map == iterator) { /*change list head if head is removed*/ iterator = lf->phone_number_sip_uri_map = bctbx_list_erase_link(lf->phone_number_sip_uri_map, iterator); @@ -2193,7 +2193,7 @@ int linphone_friend_get_capabilities(const LinphoneFriend *lf) { if (!presence) continue; capabilities |= linphone_presence_model_get_capabilities(presence); } - bctbx_list_free_with_data(phones, bctbx_free); + bctbx_list_free_with_data(phones, (bctbx_list_free_func)bctbx_free); return capabilities; } @@ -2226,7 +2226,8 @@ bool_t linphone_friend_has_capability_with_version(const LinphoneFriend *lf, if (!presence) continue; if (linphone_presence_model_has_capability_with_version(presence, capability, version)) result = TRUE; } - bctbx_list_free_with_data(phones, bctbx_free); + + bctbx_list_free_with_data(phones, (bctbx_list_free_func)bctbx_free); return result; } diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index e9895e1c6f753e1c7e1a225dd0594edbc61715dd..02bd2651e418084ffd39ca2171079a0b90e2f6fc 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -363,6 +363,7 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList linphone_friend_set_name(lf, name); linphone_free_xml_text_content(name); } + linphone_free_xml_text_content(uri); } } if (name_object) xmlXPathFreeObject(name_object); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 26795f70539d750ad671b23e46233b77fbea9c72..7a71665778f0e6e021af7721ee4a6d012e01a93f 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1721,9 +1721,10 @@ static void bodyless_config_read(LinphoneCore *lc) { linphone_core_clear_bodyless_friend_lists(lc); bctbx_list_t *bodyless_lists = linphone_config_get_string_list(lc->config, "sip", "bodyless_lists", NULL); - while (bodyless_lists) { - char *name = (char *)bctbx_list_get_data(bodyless_lists); - bodyless_lists = bctbx_list_next(bodyless_lists); + bctbx_list_t *it = bodyless_lists; + while (it) { + char *name = (char *)bctbx_list_get_data(it); + it = bctbx_list_next(it); LinphoneAddress *addr = linphone_address_new(name); if (!addr) { bctbx_free(name); @@ -1747,6 +1748,7 @@ static void bodyless_config_read(LinphoneCore *lc) { linphone_core_add_friend_list(lc, friendList); linphone_friend_list_unref(friendList); } + if (bodyless_lists) bctbx_list_free(bodyless_lists); } void linphone_core_invalidate_friends_maps(LinphoneCore *lc) { diff --git a/coreapi/logging.c b/coreapi/logging.c index 2104717764a7acde44c2a6af5dc10d96da62c4b4..afe7d1a0b66999433409a8e7e28565e250d5deea 100644 --- a/coreapi/logging.c +++ b/coreapi/logging.c @@ -183,6 +183,7 @@ void linphone_logging_service_unref(LinphoneLoggingService *service) { static void _linphone_logging_service_uninit(LinphoneLoggingService *log_service) { if (log_service->log_handler) bctbx_remove_log_handler(log_service->log_handler); + if (log_service->domain) bctbx_free(log_service->domain); _linphone_logging_service_clear_callbacks(log_service); linphone_logging_service_cbs_unref(log_service->cbs); } diff --git a/coreapi/presence.c b/coreapi/presence.c index a1bcf844fc93a7c0f6a97ee016c28520243dcfae..c1c7659ec55302afe42f2cad3424f7d9e3823676 100644 --- a/coreapi/presence.c +++ b/coreapi/presence.c @@ -166,6 +166,7 @@ static void presence_service_uninit(LinphonePresenceService *service) { if (service->contact != NULL) { ms_free(service->contact); } + if (service->service_descriptions) bctbx_list_free_with_data(service->service_descriptions, bctbx_free); bctbx_list_for_each(service->notes, presence_note_unref); bctbx_list_free(service->notes); bctbx_mmap_cchar_delete_with_data(service->capabilities, bctbx_free); @@ -838,40 +839,62 @@ static const float EPSILON = 0.1f; bool_t linphone_presence_service_has_capability_with_version(const LinphonePresenceService *service, const LinphoneFriendCapability capability, float version) { + bool_t value = FALSE; + const auto &it = bctbx_map_cchar_find_key(service->capabilities, capability_to_string(capability).c_str()); - if (!bctbx_iterator_equals(it, bctbx_map_cchar_end(service->capabilities))) - return static_cast<bool_t>( + const auto &end = bctbx_map_cchar_end(service->capabilities); + + if (!bctbx_iterator_equals(it, end)) + value = static_cast<bool_t>( fabs(std::stof(std::string((const char *)bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it)))) - version) < EPSILON); - return FALSE; + bctbx_iterator_cchar_delete(it); + bctbx_iterator_cchar_delete(end); + + return value; } bool_t linphone_presence_service_has_capability_with_version_or_more(const LinphonePresenceService *service, const LinphoneFriendCapability capability, float version) { + bool_t value = FALSE; + const auto &it = bctbx_map_cchar_find_key(service->capabilities, capability_to_string(capability).c_str()); - if (!bctbx_iterator_equals(it, bctbx_map_cchar_end(service->capabilities))) - return static_cast<bool_t>(std::stof(std::string((const char *)bctbx_pair_cchar_get_second( - bctbx_iterator_cchar_get_pair(it)))) >= version); + const auto &end = bctbx_map_cchar_end(service->capabilities); - return FALSE; + if (!bctbx_iterator_equals(it, end)) + value = static_cast<bool_t>(std::stof(std::string((const char *)bctbx_pair_cchar_get_second( + bctbx_iterator_cchar_get_pair(it)))) >= version); + + bctbx_iterator_cchar_delete(it); + bctbx_iterator_cchar_delete(end); + + return value; } float linphone_presence_service_get_capability_version(const LinphonePresenceService *service, const LinphoneFriendCapability capability) { + float value = -1.0; + const auto &it = bctbx_map_cchar_find_key(service->capabilities, capability_to_string(capability).c_str()); - if (!bctbx_iterator_equals(it, bctbx_map_cchar_end(service->capabilities))) - return std::stof(std::string((const char *)bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it)))); + const auto &end = bctbx_map_cchar_end(service->capabilities); - return -1.0; + if (!bctbx_iterator_equals(it, end)) + value = std::stof(std::string((const char *)bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it)))); + + bctbx_iterator_cchar_delete(it); + bctbx_iterator_cchar_delete(end); + + return value; } void linphone_presence_service_add_capability(LinphonePresenceService *service, const char *capability_name, const char *version) { - const bctbx_pair_cchar_t *pair = bctbx_pair_cchar_new(capability_name, (void *)version); - bctbx_map_cchar_insert(service->capabilities, (const bctbx_pair_t *)pair); + bctbx_pair_cchar_t *pair = bctbx_pair_cchar_new(capability_name, (void *)version); + bctbx_map_cchar_insert(service->capabilities, (bctbx_pair_t *)pair); + bctbx_pair_cchar_delete((bctbx_pair_t *)pair); } unsigned int linphone_presence_service_get_nb_notes(const LinphonePresenceService *service) { @@ -1459,14 +1482,15 @@ static int process_pidf_xml_presence_services(xmlparsing_context_t *xml_ctx, Lin services = bctbx_list_append(services, ms_strdup(service_id)); if (service) { - linphone_presence_service_add_capability(service, ms_strdup(service_id), - ms_strdup(version)); + linphone_presence_service_add_capability(service, service_id, ms_strdup(version)); } linphone_free_xml_text_content(service_id); linphone_free_xml_text_content(version); } } + + xmlXPathFreeObject(service_descriptions); } if (service) { diff --git a/include/linphone/FlexiAPIClient.hh b/include/linphone/FlexiAPIClient.hh index 73b302e7de79095c624acafb761eb40c374c4344..a5b9efe5f69de57597683fff300135095f87d7c4 100644 --- a/include/linphone/FlexiAPIClient.hh +++ b/include/linphone/FlexiAPIClient.hh @@ -17,13 +17,15 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <functional> +#include <json/json.h> + +#include <belle-sip/listener.h> + #include "linphone/account_creator.h" #include "linphone/core.h" #include "linphone/lpconfig.h" -#include <functional> -#include <json/json.h> - using namespace LinphonePrivate; using namespace std; @@ -33,7 +35,7 @@ struct belle_sip_auth_event; typedef struct belle_http_response_event belle_http_response_event_t; typedef struct belle_sip_auth_event belle_sip_auth_event_t; -class LINPHONE_PUBLIC FlexiAPIClient : public enable_shared_from_this<FlexiAPIClient> { +class LINPHONE_PUBLIC FlexiAPIClient { public: class LINPHONE_PUBLIC Response { public: @@ -68,7 +70,6 @@ public: function<void(const Response &)> success; function<void(const Response &)> error; LinphoneCore *core; - shared_ptr<FlexiAPIClient> mSelf; }; FlexiAPIClient(LinphoneCore *lc); @@ -146,12 +147,12 @@ public: FlexiAPIClient *useTestAdminAccount(bool test); // Callbacks handlers - FlexiAPIClient *then(function<void(Response)> success); - FlexiAPIClient *error(function<void(Response)> error); + FlexiAPIClient *then(const function<void(Response)> &success); + FlexiAPIClient *error(const function<void(Response)> &error); private: LinphoneCore *mCore; - Callbacks mRequestCallbacks; + shared_ptr<Callbacks> mRequestCallbacks; const char *mApiKey; bool mUseTestAdminAccount; @@ -159,6 +160,8 @@ private: void prepareAndSendRequest(string path, string type); void prepareAndSendRequest(string path, string type, JsonParams params); static void processResponse(void *ctx, const belle_http_response_event_t *event) noexcept; + static void processIoError(void *ctx, const belle_sip_io_error_event_t *event) noexcept; + static void processTimeout(void *ctx, const belle_sip_timeout_event_t *event) noexcept; static void processAuthRequested(void *ctx, belle_sip_auth_event_t *event) noexcept; string urlEncode(const string &value); }; \ No newline at end of file diff --git a/src/FlexiAPIClient.cc b/src/FlexiAPIClient.cc index f8cc3b449d07045a1699646a9381ba9b120c77b0..2432fd31fb0d524cec9e7386db437381bb094b3f 100644 --- a/src/FlexiAPIClient.cc +++ b/src/FlexiAPIClient.cc @@ -59,8 +59,9 @@ FlexiAPIClient::FlexiAPIClient(LinphoneCore *lc) { mApiKey = nullptr; mUseTestAdminAccount = false; + mRequestCallbacks = make_shared<Callbacks>(); // Assign the core there as well to keep it in the callback contexts - mRequestCallbacks.core = lc; + mRequestCallbacks->core = lc; } /** @@ -412,13 +413,13 @@ FlexiAPIClient *FlexiAPIClient::useTestAdminAccount(bool test) { * Callback requests */ -FlexiAPIClient *FlexiAPIClient::then(function<void(FlexiAPIClient::Response)> success) { - mRequestCallbacks.success = success; +FlexiAPIClient *FlexiAPIClient::then(const function<void(FlexiAPIClient::Response)> &success) { + mRequestCallbacks->success = success; return this; } -FlexiAPIClient *FlexiAPIClient::error(function<void(FlexiAPIClient::Response)> error) { - mRequestCallbacks.error = error; +FlexiAPIClient *FlexiAPIClient::error(const function<void(FlexiAPIClient::Response)> &error) { + mRequestCallbacks->error = error; return this; } @@ -433,7 +434,7 @@ void FlexiAPIClient::prepareAndSendRequest(string path, string type) { } void FlexiAPIClient::prepareAndSendRequest(string path, string type, JsonParams params) { - mRequestCallbacks.mSelf = shared_from_this(); + auto cb = make_unique<shared_ptr<Callbacks>>(mRequestCallbacks); belle_http_request_listener_callbacks_t internalCallbacks = {}; belle_http_request_listener_t *listener; belle_http_request_t *req; @@ -477,8 +478,11 @@ void FlexiAPIClient::prepareAndSendRequest(string path, string type, JsonParams belle_sip_message_add_header(BELLE_SIP_MESSAGE(req), BELLE_SIP_HEADER(userAgentHeader)); internalCallbacks.process_response = processResponse; + internalCallbacks.process_io_error = processIoError; + internalCallbacks.process_timeout = processTimeout; internalCallbacks.process_auth_requested = processAuthRequested; - listener = belle_http_request_listener_create_from_callbacks(&internalCallbacks, &mRequestCallbacks); + + listener = belle_http_request_listener_create_from_callbacks(&internalCallbacks, cb.release()); belle_http_provider_send_request(mCore->http_provider, req, listener); belle_sip_object_data_set(BELLE_SIP_OBJECT(req), "listener", listener, belle_sip_object_unref); @@ -486,9 +490,7 @@ void FlexiAPIClient::prepareAndSendRequest(string path, string type, JsonParams } void FlexiAPIClient::processResponse(void *ctx, const belle_http_response_event_t *event) noexcept { - auto cb = static_cast<Callbacks *>(ctx); - auto self = cb->mSelf; // Keep an instance of self. - cb->mSelf = nullptr; // Allow callbacks to reset cb if needed. + auto cb = unique_ptr<shared_ptr<Callbacks>>(static_cast<shared_ptr<Callbacks> *>(ctx)); try { FlexiAPIClient::Response response; @@ -497,17 +499,18 @@ void FlexiAPIClient::processResponse(void *ctx, const belle_http_response_event_ int code = belle_http_response_get_status_code(event->response); response.code = code; + auto cbo = *cb; if (code >= 200 && code < 300) { belle_sip_body_handler_t *body = belle_sip_message_get_body_handler(BELLE_SIP_MESSAGE(event->response)); char *content = belle_sip_object_to_string(body); response.body = content; ms_free(content); - if (cb->success) { - cb->success(response); + if (cbo->success) { + cbo->success(response); } - } else if (cb->error) { - cb->error(response); + } else if (cbo->error) { + cbo->error(response); } } @@ -516,14 +519,22 @@ void FlexiAPIClient::processResponse(void *ctx, const belle_http_response_event_ } } +void FlexiAPIClient::processIoError(void *ctx, [[maybe_unused]] const belle_sip_io_error_event_t *event) noexcept { + auto cb = unique_ptr<shared_ptr<Callbacks>>(static_cast<shared_ptr<Callbacks> *>(ctx)); +} + +void FlexiAPIClient::processTimeout(void *ctx, [[maybe_unused]] const belle_sip_timeout_event_t *event) noexcept { + auto cb = unique_ptr<shared_ptr<Callbacks>>(static_cast<shared_ptr<Callbacks> *>(ctx)); +} + void FlexiAPIClient::processAuthRequested(void *ctx, belle_sip_auth_event_t *event) noexcept { - auto cb = static_cast<Callbacks *>(ctx); + auto cb = static_cast<shared_ptr<Callbacks> *>(ctx); try { const char *username = belle_sip_auth_event_get_username(event); const char *domain = belle_sip_auth_event_get_domain(event); - linphone_core_fill_belle_sip_auth_event(cb->core, event, username, domain); + linphone_core_fill_belle_sip_auth_event((*cb)->core, event, username, domain); } catch (const std::exception &e) { lError() << e.what(); } diff --git a/src/account_creator/main.cpp b/src/account_creator/main.cpp index 494b5b7fcb373076075e52e6c958713134919898..9c05d046d0053c631ff070a915a982ba58571efe 100644 --- a/src/account_creator/main.cpp +++ b/src/account_creator/main.cpp @@ -471,6 +471,10 @@ void linphone_account_creator_reset(LinphoneAccountCreator *creator) { reset_field(&creator->domain); reset_field(&creator->route); reset_field(&creator->algorithm); + reset_field(&creator->token); + reset_field(&creator->pn_prid); + reset_field(&creator->pn_param); + reset_field(&creator->pn_provider); if (creator->proxy_cfg) { linphone_proxy_config_unref(creator->proxy_cfg); diff --git a/src/c-wrapper/api/c-chat-room.cpp b/src/c-wrapper/api/c-chat-room.cpp index c04027b25c52dcc6530d560656abb670bae10f3a..e9406b5b70d496315c6519e4d77b7ab06dcc9863 100644 --- a/src/c-wrapper/api/c-chat-room.cpp +++ b/src/c-wrapper/api/c-chat-room.cpp @@ -63,6 +63,7 @@ static void _linphone_chat_room_constructor(BCTBX_UNUSED(LinphoneChatRoom *cr)) static void _linphone_chat_room_destructor(LinphoneChatRoom *cr) { _linphone_chat_room_clear_callbacks(cr); + if (cr->composingAddresses) bctbx_list_free(cr->composingAddresses); } void linphone_chat_room_allow_multipart(LinphoneChatRoom *room) { @@ -501,6 +502,7 @@ void linphone_chat_room_set_subject(LinphoneChatRoom *cr, const char *subject) { const bctbx_list_t *linphone_chat_room_get_composing_addresses(LinphoneChatRoom *cr) { LinphonePrivate::ChatRoomLogContextualizer logContextualizer(cr); list<shared_ptr<LinphonePrivate::Address>> addresses = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getComposingAddresses(); + if (cr->composingAddresses) bctbx_list_free(cr->composingAddresses); cr->composingAddresses = LinphonePrivate::Utils::listToCBctbxList<LinphoneAddress, LinphonePrivate::Address>(addresses); return cr->composingAddresses; diff --git a/src/sal/potential_config_graph.cpp b/src/sal/potential_config_graph.cpp index b96e1ee1a78bd6d9b78628931ed6648c2a637ee7..f7e341f99dd8515972f93f705a9497cbddf77314 100644 --- a/src/sal/potential_config_graph.cpp +++ b/src/sal/potential_config_graph.cpp @@ -268,7 +268,9 @@ bool PotentialCfgGraph::processMediaPcfg(const unsigned int &idx, const belle_sd auto attr_configs = createPConfigFromAttribute(lAttribute, mediaAcap, mediaTcap); if (attr_configs.acap.empty() && attr_configs.tcap.empty()) { lInfo() << "Unable to build a potential config for id " << id; - unparsed_config[id] = belle_sip_object_to_string(lAttribute); + char *attrString = belle_sip_object_to_string(lAttribute); + unparsed_config[id] = attrString; + belle_sip_free(attrString); } else { config[id] = attr_configs; } diff --git a/tester/accountmanager.c b/tester/accountmanager.c index f43fda3f2188d79230dcfd19e3dd7bc724489641..c877f9075c515e63eb1173bb5b4ccfc1feed33a3 100644 --- a/tester/accountmanager.c +++ b/tester/accountmanager.c @@ -60,6 +60,7 @@ static Account *account_new(LinphoneAddress *identity, const char *unique_id) { void account_destroy(Account *obj) { if (obj->uuid) bctbx_free(obj->uuid); + if (obj->phone_alias) bctbx_free(obj->phone_alias); linphone_address_unref(obj->identity); linphone_address_unref(obj->modified_identity); ms_free(obj->password); diff --git a/tester/audio_video_conference_tester.c b/tester/audio_video_conference_tester.c index f34da0c012b0d035da6f8e87a22badda3e1528cc..f2a9097462271a786e766f68359b926e490d9b11 100644 --- a/tester/audio_video_conference_tester.c +++ b/tester/audio_video_conference_tester.c @@ -35,14 +35,6 @@ #define unlink _unlink #endif -void destroy_mgr_in_conference(LinphoneCoreManager *mgr) { - if (mgr->user_info) { - ms_free((int *)mgr->user_info); - } - - linphone_core_manager_destroy(mgr); -} - static void set_video_in_call(LinphoneCoreManager *m1, LinphoneCoreManager *m2, bool_t enable_video, @@ -2168,7 +2160,6 @@ static void simple_conference_with_user_defined_layout(const LinphoneConferenceL const LinphoneMediaEncryption encryption) { LinphoneConferenceServer *focus = linphone_conference_server_new("conference_focus_rc", TRUE); LinphoneCoreManager *focus_mgr = ((LinphoneCoreManager *)focus); - setup_mgr_for_conference(focus_mgr, NULL); linphone_core_enable_conference_server(focus_mgr->lc, TRUE); LinphoneCoreManager *marie = create_mgr_for_conference("marie_rc", TRUE, NULL); diff --git a/tester/call_multicast_tester.c b/tester/call_multicast_tester.c index 63476b0d4cb24d1ea97a2b1ae5b68c64160ea108..695099c8d6b7b0825ad0016d0c465ecb62bc7bd8 100644 --- a/tester/call_multicast_tester.c +++ b/tester/call_multicast_tester.c @@ -246,7 +246,7 @@ static void early_media_with_multicast_base(bool_t video) { } end_call(marie, pauline); } - ms_free(lcs); + bctbx_list_free(lcs); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(pauline2); diff --git a/tester/call_recovery_tester.c b/tester/call_recovery_tester.c index 60ed69466fa666a9180a6e89f30395d5f07b9ef5..86474a4f17ea2fd14f490d4dff8520b7535618e8 100644 --- a/tester/call_recovery_tester.c +++ b/tester/call_recovery_tester.c @@ -118,6 +118,8 @@ static void recovered_call_on_network_switch_in_early_state(LinphoneCoreManager /*to make sure the call is only "repaired one time"*/ BC_ASSERT_STRING_EQUAL(linphone_call_log_get_call_id(linphone_call_get_call_log(outgoing_call)), repared_callid); + bctbx_free(repared_callid); + linphone_call_terminate(incoming_call); BC_ASSERT_TRUE(wait_for(callerMgr->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallEnd, 1)); BC_ASSERT_TRUE(wait_for(callerMgr->lc, pauline->lc, &callerMgr->stat.number_of_LinphoneCallReleased, 1)); diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index a906047c70e5333fc86ce5e397e121e44359feca..717d4dce3c781a817549d5a7790fa63e0876d399 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -5831,6 +5831,7 @@ static void rtptm_on_schedule(RtpTransportModifier *rtptm) { } meta_rtp_transport_modifier_inject_packet_to_send(rtptm->transport, rtptm, msg, 0); + freemsg(msg); } msg = NULL; @@ -6065,10 +6066,14 @@ static void custom_rtp_modifier(bool_t pauseResumeTest, bool_t recordTest) { end: // Since we didn't free the resources of our RTP transport modifier in the rtptm_destroy callback, we'll do it here if (data_pauline) { + ms_queue_flush(&data_pauline->to_send); + ms_queue_flush(&data_pauline->to_recv); ms_free(data_pauline); } ms_free(rtptm_pauline); if (data_marie) { + ms_queue_flush(&data_marie->to_send); + ms_queue_flush(&data_marie->to_recv); ms_free(data_marie); } ms_free(rtptm_marie); diff --git a/tester/conference-event-tester.cpp b/tester/conference-event-tester.cpp index b6cf01ef97aff1051b4ed9d650febd1843351ad2..71cef5d9a454991e360fb770c015c1f44930a066 100644 --- a/tester/conference-event-tester.cpp +++ b/tester/conference-event-tester.cpp @@ -1249,7 +1249,7 @@ void participant_not_added_parsing() { linphone_address_unref(aliceAddr); linphone_address_unref(frankAddr); tester = nullptr; - linphone_core_manager_destroy(marie); + destroy_mgr_in_conference(marie); } void participant_deleted_parsing() { diff --git a/tester/eventapi_tester.c b/tester/eventapi_tester.c index 86cf09978f4eaca968357dde4ac8d6886d707d53..9a8a97be2013a40f843bfbe1e1c865d330b113e5 100644 --- a/tester/eventapi_tester.c +++ b/tester/eventapi_tester.c @@ -625,6 +625,7 @@ static void publish_expired(void) { linphone_event_unref(lev); linphone_core_manager_stop(marie); linphone_core_manager_uninit(marie); + bctbx_free(marie); BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphonePublishCleared, 1, 5000)); diff --git a/tester/external_domain_tester.c b/tester/external_domain_tester.c index 6aade58cb142f4672059913f5df857a7472eed1c..8f6e4f78b0ef77036fc2cf982108b00cdedc95aa 100644 --- a/tester/external_domain_tester.c +++ b/tester/external_domain_tester.c @@ -275,8 +275,9 @@ static void group_chat_hfts(bool_t encryption, } bctbx_list_t *tmpCoresManagerList = bctbx_list_append(NULL, manager_to_restart); - init_core_for_conference(tmpCoresManagerList); + bctbx_list_t *tmpList = init_core_for_conference(tmpCoresManagerList); bctbx_list_free(tmpCoresManagerList); + bctbx_list_free(tmpList); linphone_core_manager_start(manager_to_restart, TRUE); diff --git a/tester/flexiapiclient-tester.cpp b/tester/flexiapiclient-tester.cpp index 0e71e5742bfa8a3083bacb0e56b0704811f15ccd..f0e90b2b57582973acaa5e242448cb4ef411ff2f 100644 --- a/tester/flexiapiclient-tester.cpp +++ b/tester/flexiapiclient-tester.cpp @@ -126,7 +126,9 @@ static void flexiapiCreateAccount() { int code = 0; int fetched = 0; int id = 0; - string username = string("test_").append(sal_get_random_token_lowercase(12)); + char *token = sal_get_random_token_lowercase(12); + string username = string("test_").append(token); + bctbx_free(token); string resolvedDomain; bool activated = true; diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 49508bcef64532e5f871a3af4149338788996570..a2c4bf0ab6a6ef0ca857bc35b45a1f1fd7f9cabe 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -697,6 +697,8 @@ static void call_forking_with_push_notification_multiple(void) { BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallReleased, 1, 5000)); BC_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallReleased, 1, 5000)); } + + bctbx_list_free(lcs); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); @@ -1338,6 +1340,8 @@ static void test_list_subscribe(void) { ms_free(subscribe_content); linphone_address_unref(list_name); linphone_content_unref(content); + + bctbx_list_free(lcs); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(laure); diff --git a/tester/local_conference_tester_functions.h b/tester/local_conference_tester_functions.h index 118aa29cbe55915057491d16b3e49ebf9d496b34..dff7bc83bf4cb5f1d11232c5f044868f92e5423a 100644 --- a/tester/local_conference_tester_functions.h +++ b/tester/local_conference_tester_functions.h @@ -87,7 +87,7 @@ public: start(true); } - void reStart(bool check_for_proxies = true) { + virtual void reStart(bool check_for_proxies = true) { linphone_core_manager_reinit(mMgr.get()); mPreStart(); start(check_for_proxies); @@ -159,6 +159,11 @@ public: mFocus(nullptr) { } + void reStart(bool check_for_proxies = true) override { + if (mMgr->user_info) bctbx_free(mMgr->user_info); + ConfCoreManager::reStart(check_for_proxies); + } + void deleteChatRoomSync(AbstractChatRoom &chatroom) { linphone_core_delete_chat_room(getLc(), L_GET_C_BACK_PTR(&chatroom)); CoreManagerAssert({*mFocus, *this}).wait([&chatroom] { diff --git a/tester/message_tester.c b/tester/message_tester.c index 0d8f0932a4295bf26966a2a37674ce10f5762140..ccf7be1e3ce7f0261a72d102fc5f4cf8a386e263 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -385,7 +385,7 @@ void text_message_base_with_text_and_forward(LinphoneCoreManager *marie, LinphoneAddress *clonedContact = linphone_address_clone(contact); linphone_address_clean(clonedContact); // Needed to remove GRUU bctbx_list_t *expected_reaction_from = - bctbx_list_append(NULL, ms_strdup(linphone_address_as_string_uri_only(clonedContact))); + bctbx_list_append(NULL, linphone_address_as_string_uri_only(clonedContact)); linphone_address_unref(clonedContact); check_reactions(recv_msg, 1, expected_reaction, expected_reaction_from); bctbx_list_free(expected_reaction); @@ -411,6 +411,60 @@ void text_message_base_with_text_and_forward(LinphoneCoreManager *marie, linphone_chat_message_unref(msg); } +void check_reactions(LinphoneChatMessage *message, + size_t expected_reactions_count, + const bctbx_list_t *expected_reactions, + const bctbx_list_t *expected_reactions_from) { + bctbx_list_t *reactions = linphone_chat_message_get_reactions(message); + bctbx_list_t *reactions_it = reactions; + bctbx_list_t *expected_reactions_it = (bctbx_list_t *)expected_reactions; + bctbx_list_t *expected_reactions_from_it = (bctbx_list_t *)expected_reactions_from; + BC_ASSERT_PTR_NOT_NULL(reactions); + + if (reactions_it) { + size_t count = bctbx_list_size(reactions); + BC_ASSERT_EQUAL(count, expected_reactions_count, size_t, "%zu"); + for (size_t i = 0; i < count; i++) { + const LinphoneChatMessageReaction *reaction = + (const LinphoneChatMessageReaction *)bctbx_list_get_data(reactions_it); + reactions_it = bctbx_list_next(reactions_it); + + const char *expected_reaction = (const char *)bctbx_list_get_data(expected_reactions_it); + expected_reactions_it = bctbx_list_next(expected_reactions_it); + + const char *expected_reaction_from = (const char *)bctbx_list_get_data(expected_reactions_from_it); + expected_reactions_from_it = bctbx_list_next(expected_reactions_from_it); + + const char *reaction_body = linphone_chat_message_reaction_get_body(reaction); + BC_ASSERT_STRING_EQUAL(reaction_body, expected_reaction); + + const LinphoneAddress *from = linphone_chat_message_reaction_get_from_address(reaction); + char *address_as_string = linphone_address_as_string_uri_only(from); + BC_ASSERT_STRING_EQUAL(address_as_string, expected_reaction_from); + bctbx_free(address_as_string); + } + } + bctbx_list_free_with_data(reactions, (bctbx_list_free_func)linphone_chat_message_reaction_unref); +} + +void liblinphone_tester_chat_message_reaction_received(LinphoneChatMessage *msg, + const LinphoneChatMessageReaction *reaction) { + BC_ASSERT_PTR_NOT_NULL(msg); + BC_ASSERT_PTR_NOT_NULL(reaction); + + const LinphoneAddress *address = linphone_chat_message_reaction_get_from_address(reaction); + BC_ASSERT_PTR_NOT_NULL(address); + const char *body = linphone_chat_message_reaction_get_body(reaction); + BC_ASSERT_STRING_EQUAL(body, "ðŸ‘"); + + bctbx_list_t *expected_reaction = bctbx_list_append(NULL, "ðŸ‘"); + bctbx_list_t *expected_reaction_from = + bctbx_list_append(NULL, ms_strdup(linphone_address_as_string_uri_only(address))); + check_reactions(msg, 1, expected_reaction, expected_reaction_from); + bctbx_list_free(expected_reaction); + bctbx_list_free_with_data(expected_reaction_from, (bctbx_list_free_func)ms_free); +} + void text_message_base_with_text(LinphoneCoreManager *marie, LinphoneCoreManager *pauline, const char *text, diff --git a/tester/presence_server_tester.c b/tester/presence_server_tester.c index 782758173d9acf47e991cda3b034371f033ebcd1..1fbaf7b05d5c0b7b102c92b3e4d447af38f9a938 100644 --- a/tester/presence_server_tester.c +++ b/tester/presence_server_tester.c @@ -298,6 +298,7 @@ static void subscribe_with_late_publish(void) { pauline_lp = linphone_core_get_config(pauline->lc); lf_identity = linphone_address_as_string_uri_only(marie->identity); lf = linphone_core_create_friend_with_address(pauline->lc, lf_identity); + bctbx_free(lf_identity); linphone_config_set_int(pauline_lp, "sip", "subscribe_expires", 10); @@ -397,6 +398,7 @@ static void test_forked_subscribe_notify_publish(void) { pauline_lp = linphone_core_get_config(pauline->lc); lf_identity = linphone_address_as_string_uri_only(marie->identity); lf = linphone_core_create_friend_with_address(pauline->lc, lf_identity); + bctbx_free(lf_identity); linphone_config_set_int(pauline_lp, "sip", "subscribe_expires", 5); @@ -437,6 +439,7 @@ static void test_forked_subscribe_notify_publish(void) { /*wait for new status*/ BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphonePresenceActivityMeeting, 1, 3000)); + bctbx_list_free(lcs); linphone_friend_unref(lf); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); @@ -941,6 +944,7 @@ static void test_presence_list_subscribe_with_error(bool_t io_error) { lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusAway, int, "%d"); + bctbx_list_free(lcs); linphone_core_manager_destroy(laure); linphone_core_manager_destroy(pauline); } @@ -1041,6 +1045,7 @@ static void presence_list_subscribe_network_changes(void) { lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusAway, int, "%d"); + bctbx_list_free(lcs); linphone_core_manager_destroy(laure); linphone_core_manager_destroy(pauline); } @@ -1177,8 +1182,9 @@ static void long_term_presence_list(void) { presence = linphone_friend_get_presence_model_for_uri_or_tel(f1, e164_phone_number); if (BC_ASSERT_PTR_NOT_NULL(presence)) { - BC_ASSERT_STRING_EQUAL(linphone_presence_model_get_contact(presence), - "sip:liblinphone_tester@sip.example.org"); + char *contact = linphone_presence_model_get_contact(presence); + BC_ASSERT_STRING_EQUAL(contact, "sip:liblinphone_tester@sip.example.org"); + bctbx_free(contact); } BC_ASSERT_TRUE(linphone_friend_is_presence_received(f1)); @@ -1672,6 +1678,7 @@ static void publish_with_expire_timestamp_refresh_base(bool_t refresh_timestamps char *pauline_identity = linphone_address_as_string(pauline->identity); LinphoneFriend *marie_pauline_friend = linphone_core_create_friend_with_address(marie->lc, pauline_identity); + bctbx_free(pauline_identity); linphone_friend_list_add_friend(marie_lfl, marie_pauline_friend); linphone_friend_list_update_subscriptions(marie_lfl); @@ -2314,6 +2321,7 @@ static void notify_friend_capabilities_after_publish(void) { specs = bctbx_list_append(specs, "groupchat/1.1"); specs = bctbx_list_append(specs, "lime/1.5"); linphone_core_set_linphone_specs_list(pauline->lc, specs); + bctbx_list_free(specs); linphone_core_manager_start(marie, TRUE); linphone_core_manager_start(pauline, TRUE); @@ -2453,6 +2461,7 @@ static void notify_friend_capabilities_with_alias(void) { specs = bctbx_list_append(specs, "groupchat/1.1"); specs = bctbx_list_append(specs, "lime/1.5"); linphone_core_set_linphone_specs_list(marie->lc, specs); + bctbx_list_free(specs); linphone_core_manager_start(marie, TRUE); laure = linphone_core_manager_create2("marie_rc", e164Laure); @@ -2544,6 +2553,7 @@ static void notify_search_result_capabilities_with_alias(void) { specs = bctbx_list_append(specs, "groupchat/1.1"); specs = bctbx_list_append(specs, "lime/1.5"); linphone_core_set_linphone_specs_list(marie->lc, specs); + bctbx_list_free(specs); linphone_core_manager_start(marie, TRUE); LinphoneCoreManager *pauline = diff --git a/tester/recorder_tester.c b/tester/recorder_tester.c index c500f1df4757e42348022af846de2555974e1610..46da82e89ae1c461fe140e683179d85718e1f3f3 100644 --- a/tester/recorder_tester.c +++ b/tester/recorder_tester.c @@ -63,7 +63,7 @@ static void record_file(const char *filename, BCTBX_UNUSED(bool_t supported_format), BCTBX_UNUSED(const char *audio_mime), const char *video_mime, - LinphoneRecorderFileFormat format) { + LinphoneRecorderFileFormat file_format) { LinphoneCoreManager *lc_manager = linphone_core_manager_create("marie_rc"); LinphoneRecorder *recorder; int res = 0; @@ -82,7 +82,7 @@ static void record_file(const char *filename, LinphoneRecorderParams *params = linphone_core_create_recorder_params(lc_manager->lc); linphone_recorder_params_set_webcam_name(params, linphone_core_get_video_device(lc_manager->lc)); - linphone_recorder_params_set_file_format(params, format); + linphone_recorder_params_set_file_format(params, file_format); linphone_recorder_params_set_video_codec(params, video_mime); recorder = linphone_core_create_recorder(lc_manager->lc, params); linphone_recorder_params_unref(params); diff --git a/tester/register_tester.c b/tester/register_tester.c index 57647a30690b98f67850cc3de492d22b531cdc25..15b6a0fb98b316965d4607f8923f2b312397c837 100644 --- a/tester/register_tester.c +++ b/tester/register_tester.c @@ -193,7 +193,11 @@ static void register_with_route(LinphoneCoreManager *lcm, const char *domain, co if (transport) linphone_core_set_transports(lcm->lc, transport); LinphoneAccountParams *accountParams = linphone_core_create_account_params(lcm->lc); linphone_account_params_set_identity_address(accountParams, from); - linphone_account_params_set_routes_addresses(accountParams, bctbx_list_new(routeAddress)); + + bctbx_list_t *routes = bctbx_list_new(routeAddress); + linphone_account_params_set_routes_addresses(accountParams, routes); + bctbx_list_free(routes); + linphone_account_params_set_server_addr(accountParams, route); linphone_account_params_set_register_enabled(accountParams, TRUE); @@ -844,13 +848,13 @@ static void transport_dont_bind(void) { BC_ASSERT_EQUAL(linphone_transports_get_udp_port(tr), 0, int, "%i"); BC_ASSERT_EQUAL(linphone_transports_get_tcp_port(tr), LC_SIP_TRANSPORT_DONTBIND, int, "%i"); BC_ASSERT_EQUAL(linphone_transports_get_tls_port(tr), LC_SIP_TRANSPORT_DONTBIND, int, "%i"); - linphone_transports_unref(tr); // udp linphone_transports_set_tcp_port(tr, LC_SIP_TRANSPORT_DISABLED); linphone_transports_set_tls_port(tr, LC_SIP_TRANSPORT_DISABLED); linphone_transports_set_udp_port(tr, LC_SIP_TRANSPORT_DONTBIND); linphone_core_set_transports(pauline->lc, tr); + linphone_transports_unref(tr); LinphoneAccount *account = linphone_core_get_default_account(pauline->lc); LinphoneAccountParams *params = linphone_account_params_clone(linphone_account_get_params(account)); @@ -1088,16 +1092,20 @@ static void io_recv_error_late_recovery(void) { (register_ok - number_of_udp_proxy) + register_ok /*because 1 udp*/)); BC_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed, 0, int, "%d"); - BC_ASSERT_TRUE(wait_for_list(lcs = bctbx_list_append(NULL, lc), &counters->number_of_LinphoneRegistrationFailed, + lcs = bctbx_list_append(NULL, lc); + + BC_ASSERT_TRUE(wait_for_list(lcs, &counters->number_of_LinphoneRegistrationFailed, (register_ok - number_of_udp_proxy), sal_get_refresher_retry_after(linphone_core_get_sal(lc)) + 3000)); sal_set_recv_error(linphone_core_get_sal(lc), 1); /*reset*/ sal_set_send_error(linphone_core_get_sal(lc), 0); - BC_ASSERT_TRUE(wait_for_list(lcs = bctbx_list_append(NULL, lc), &counters->number_of_LinphoneRegistrationOk, + BC_ASSERT_TRUE(wait_for_list(lcs, &counters->number_of_LinphoneRegistrationOk, register_ok - number_of_udp_proxy + register_ok, sal_get_refresher_retry_after(linphone_core_get_sal(lc)) + 3000)); + + bctbx_list_free(lcs); linphone_core_manager_destroy(lcm); } } @@ -1117,8 +1125,9 @@ static void io_recv_error_without_active_register(void) { register_ok = counters->number_of_LinphoneRegistrationOk; - for (proxys = bctbx_list_copy(linphone_core_get_proxy_config_list(lc)); proxys != NULL; proxys = proxys->next) { - LinphoneProxyConfig *proxy_cfg = (LinphoneProxyConfig *)proxys->data; + proxys = bctbx_list_copy(linphone_core_get_proxy_config_list(lc)); + for (bctbx_list_t *it = proxys; it != NULL; it = it->next) { + LinphoneProxyConfig *proxy_cfg = (LinphoneProxyConfig *)it->data; linphone_proxy_config_edit(proxy_cfg); linphone_proxy_config_enableregister(proxy_cfg, FALSE); linphone_proxy_config_done(proxy_cfg); diff --git a/tester/remote-provisioning-tester.cpp b/tester/remote-provisioning-tester.cpp index 8dae1e81075ba4947402887382e4c485c74d237d..56d6c16560d6a15c0c5690aedb51dc7f4e4f2842 100644 --- a/tester/remote-provisioning-tester.cpp +++ b/tester/remote-provisioning-tester.cpp @@ -158,7 +158,9 @@ static void flexiapi_remote_provisioning_flow(void) { string remoteProvisioningURI = linphone_core_get_provisioning_uri(marie->lc); // Create a test account - string username = string("test_").append(sal_get_random_token_lowercase(12)); + char *token = sal_get_random_token_lowercase(12); + string username = string("test_").append(token); + bctbx_free(token); bool activated = false; // Required to get a confirmation key string confirmationKey; int id; @@ -225,8 +227,12 @@ static void flexiapi_remote_provisioning_contacts_list_flow(void) { unlink(friends_db); // Create a test account - string usernameContact1 = string("test_").append(sal_get_random_token_lowercase(12)); - string usernameContact2 = string("test_").append(sal_get_random_token_lowercase(12)); + char *token = sal_get_random_token_lowercase(12); + string usernameContact1 = string("test_").append(token); + bctbx_free(token); + token = sal_get_random_token_lowercase(12); + string usernameContact2 = string("test_").append(token); + bctbx_free(token); int contactId0; int contactId1; int contactId2; @@ -241,6 +247,8 @@ static void flexiapi_remote_provisioning_contacts_list_flow(void) { contactId0 = response.json()["id"].asInt(); }); + bctbx_free(addr); + wait_for_until(marie->lc, NULL, &fetched, 1, liblinphone_tester_sip_timeout); fetched = code = 0; @@ -273,7 +281,7 @@ static void flexiapi_remote_provisioning_contacts_list_flow(void) { // Link the contacts flexiAPIClient->adminAccountContactAdd(contactId0, contactId1); flexiAPIClient->adminAccountContactAdd(contactId0, contactId2) - ->then([&code, &fetched](FlexiAPIClient::Response response) { + ->then([&code, &fetched](const FlexiAPIClient::Response &response) { code = response.code; fetched = 1; }); @@ -325,15 +333,19 @@ static void flexiapi_remote_provisioning_contacts_list_flow(void) { string fullName = string(linphone_vcard_get_full_name(vcard)).substr(0, usernameContact2.length()); BC_ASSERT_STRING_EQUAL(fullName.c_str(), usernameContact2.c_str()); - BC_ASSERT_STRING_EQUAL((const char *)bctbx_list_get_data(linphone_vcard_get_extended_properties_values_by_name( - vcard, "X-LINPHONE-ACCOUNT-DTMF-PROTOCOL")), - "rfc2833"); + + bctbx_list_t *extended_properties = + linphone_vcard_get_extended_properties_values_by_name(vcard, "X-LINPHONE-ACCOUNT-DTMF-PROTOCOL"); + BC_ASSERT_STRING_EQUAL((const char *)bctbx_list_get_data(extended_properties), "rfc2833"); + bctbx_list_free_with_data(extended_properties, (bctbx_list_free_func)bctbx_free); linphone_vcard_remove_extented_properties_by_name(vcard, "X-LINPHONE-ACCOUNT-DTMF-PROTOCOL"); linphone_vcard_add_extended_property(vcard, "X-LINPHONE-ACCOUNT-DTMF-PROTOCOL", "test"); - BC_ASSERT_STRING_EQUAL((const char *)bctbx_list_get_data(linphone_vcard_get_extended_properties_values_by_name( - vcard, "X-LINPHONE-ACCOUNT-DTMF-PROTOCOL")), - "test"); + + extended_properties = + linphone_vcard_get_extended_properties_values_by_name(vcard, "X-LINPHONE-ACCOUNT-DTMF-PROTOCOL"); + BC_ASSERT_STRING_EQUAL((const char *)bctbx_list_get_data(extended_properties), "test"); + bctbx_list_free_with_data(extended_properties, (bctbx_list_free_func)bctbx_free); } BC_ASSERT_EQUAL((int)bctbx_list_size(linphone_core_get_friends_lists(marie->lc)), 2, int, "%i"); @@ -348,7 +360,7 @@ static void flexiapi_remote_provisioning_contacts_list_flow(void) { flexiAPIClient->useTestAdminAccount(true); flexiAPIClient->adminAccountContactDelete(contactId0, contactId2) - ->then([&code, &fetched](FlexiAPIClient::Response response) { + ->then([&code, &fetched](const FlexiAPIClient::Response &response) { code = response.code; fetched = 1; }); @@ -400,7 +412,7 @@ static void flexiapi_remote_provisioning_contacts_list_flow(void) { flexiAPIClient = make_shared<FlexiAPIClient>(marie->lc); flexiAPIClient->adminAccountDelete(contactId1); - flexiAPIClient->adminAccountDelete(contactId2)->then([&code, &fetched](FlexiAPIClient::Response response) { + flexiAPIClient->adminAccountDelete(contactId2)->then([&code, &fetched](const FlexiAPIClient::Response &response) { code = response.code; fetched = 1; }); @@ -410,6 +422,7 @@ static void flexiapi_remote_provisioning_contacts_list_flow(void) { linphone_core_cbs_unref(cbs); ms_free(stats); + ms_free(friends_db); linphone_core_manager_destroy(marie); } diff --git a/tester/setup_tester.c b/tester/setup_tester.c index d356900f908d48d31c0ddb9676b8e463b4dee74f..d0ebdd7609c9826c9bfc9c5379553d89a0660c92 100644 --- a/tester/setup_tester.c +++ b/tester/setup_tester.c @@ -579,6 +579,7 @@ static void linphone_config_safety_test(void) { unlink(file); bc_free(res); bc_free(file); + bctbx_free(tmpfile); } static void linphone_lpconfig_from_buffer(void) { @@ -1986,6 +1987,7 @@ static void search_friend_with_aggregation(void) { linphone_magic_search_unref(magicSearch); linphone_core_manager_destroy(manager); unlink(friends_db); + bctbx_free(friends_db); } static void search_friend_with_name_with_uppercase(void) { @@ -2232,7 +2234,7 @@ static void search_friend_get_capabilities(void) { addr = "sip:groupchat@sip.linphone.org"; group_chat_fr = linphone_core_create_friend_with_address(manager->lc, addr); group_chat_service = linphone_presence_service_new(NULL, LinphonePresenceBasicStatusOpen, NULL); - group_chat_descriptions = bctbx_list_append(group_chat_descriptions, "groupchat"); + group_chat_descriptions = bctbx_list_append(group_chat_descriptions, bctbx_strdup("groupchat")); linphone_presence_service_set_service_descriptions(group_chat_service, group_chat_descriptions); linphone_presence_model_add_service(group_chat_model, group_chat_service); linphone_friend_set_presence_model_for_uri_or_tel(group_chat_fr, addr, group_chat_model); @@ -2241,8 +2243,8 @@ static void search_friend_get_capabilities(void) { addr = "sip:lime@sip.linphone.org"; lime_fr = linphone_core_create_friend_with_address(manager->lc, addr); lime_service = linphone_presence_service_new(NULL, LinphonePresenceBasicStatusOpen, NULL); - lime_descriptions = bctbx_list_append(lime_descriptions, "groupchat"); - lime_descriptions = bctbx_list_append(lime_descriptions, "lime"); + lime_descriptions = bctbx_list_append(lime_descriptions, bctbx_strdup("groupchat")); + lime_descriptions = bctbx_list_append(lime_descriptions, bctbx_strdup("lime")); linphone_presence_service_set_service_descriptions(lime_service, lime_descriptions); linphone_presence_model_add_service(lime_model, lime_service); linphone_friend_set_presence_model_for_uri_or_tel(lime_fr, addr, lime_model); @@ -2251,9 +2253,9 @@ static void search_friend_get_capabilities(void) { addr = "sip:ephemeral@sip.linphone.org"; ephemeral_fr = linphone_core_create_friend_with_address(manager->lc, addr); ephemeral_service = linphone_presence_service_new(NULL, LinphonePresenceBasicStatusOpen, NULL); - ephemeral_descriptions = bctbx_list_append(ephemeral_descriptions, "groupchat"); - ephemeral_descriptions = bctbx_list_append(ephemeral_descriptions, "lime"); - ephemeral_descriptions = bctbx_list_append(ephemeral_descriptions, "ephemeral"); + ephemeral_descriptions = bctbx_list_append(ephemeral_descriptions, bctbx_strdup("groupchat")); + ephemeral_descriptions = bctbx_list_append(ephemeral_descriptions, bctbx_strdup("lime")); + ephemeral_descriptions = bctbx_list_append(ephemeral_descriptions, bctbx_strdup("ephemeral")); linphone_presence_service_set_service_descriptions(ephemeral_service, ephemeral_descriptions); linphone_presence_model_add_service(ephemeral_model, ephemeral_service); linphone_friend_set_presence_model_for_uri_or_tel(ephemeral_fr, addr, ephemeral_model); @@ -2303,10 +2305,6 @@ static void search_friend_get_capabilities(void) { bctbx_list_free_with_data(copy, (bctbx_list_free_func)linphone_search_result_unref); } - bctbx_list_free(group_chat_descriptions); - bctbx_list_free(lime_descriptions); - bctbx_list_free(ephemeral_descriptions); - linphone_presence_service_unref(group_chat_service); linphone_presence_service_unref(lime_service); linphone_presence_service_unref(ephemeral_service); @@ -3504,7 +3502,7 @@ static void audio_devices(void) { bctbx_list_t *sound_devices = linphone_core_get_sound_devices_list(core); int sound_devices_count = (int)bctbx_list_size(sound_devices); BC_ASSERT_GREATER_STRICT(sound_devices_count, 0, int, "%d"); - bctbx_list_free(sound_devices); + bctbx_list_free_with_data(sound_devices, (bctbx_list_free_func)bctbx_free); // Check extended audio devices list matches legacy sound devices list bctbx_list_t *audio_devices = linphone_core_get_extended_audio_devices(core); diff --git a/tester/stun_tester.c b/tester/stun_tester.c index d6847022c462e8be228675a4a8f22dd16ceac81c..483f09288d89b5ac3a70ca1c8eb98fc3c3a81499 100644 --- a/tester/stun_tester.c +++ b/tester/stun_tester.c @@ -32,7 +32,9 @@ static size_t test_stun_encode(char **buffer) { UInt96 tr_id = ms_stun_message_get_tr_id(req); tr_id.octet[0] = 11; ms_stun_message_set_tr_id(req, tr_id); - return ms_stun_message_encode(req, buffer); + size_t size = ms_stun_message_encode(req, buffer); + ms_stun_message_destroy(req); + return size; } static void linphone_stun_test_encode(void) { diff --git a/tester/tester.c b/tester/tester.c index 40a14661a605ea9c036fa3cbf22ab54b90eba683..61963ba06416097a4d7a5468db2af6fb7917a10c 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -4854,6 +4854,7 @@ LinphoneConferenceServer *linphone_conference_server_new(const char *rc_file, bo linphone_proxy_config_done(proxy); } linphone_core_add_callbacks(lm->lc, conf_srv->cbs); + setup_mgr_for_conference(lm, NULL); linphone_core_manager_start(lm, do_registration); return conf_srv; } @@ -4899,9 +4900,17 @@ create_mgr_for_conference(const char *rc_file, bool_t check_for_proxies, const c return mgr; } +void destroy_mgr_in_conference(LinphoneCoreManager *mgr) { + if (mgr->user_info != NULL) { + bctbx_free(mgr->user_info); + mgr->user_info = NULL; + } + linphone_core_manager_destroy(mgr); +} + void linphone_conference_server_destroy(LinphoneConferenceServer *conf_srv) { linphone_core_cbs_unref(conf_srv->cbs); - linphone_core_manager_destroy((LinphoneCoreManager *)conf_srv); + destroy_mgr_in_conference((LinphoneCoreManager *)conf_srv); } const char *liblinphone_tester_get_empty_rc(void) { diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index 487688bf675adc8cbc6f2fc2c28bf476e5a3253e..4b80ce708c932c930917cca4635e7f752870180f 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -165,7 +165,7 @@ static void linphone_vcard_phone_numbers_and_sip_addresses(void) { BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(sip_addresses), 2, unsigned int, "%u"); BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(phone_numbers), 1, unsigned int, "%u"); - if (phone_numbers) bctbx_list_free_with_data(phone_numbers, ms_free); + if (phone_numbers) bctbx_list_free_with_data(phone_numbers, (bctbx_list_free_func)bctbx_free); linphone_friend_unref(lf); lvc = linphone_vcard_context_get_vcard_from_buffer( @@ -180,7 +180,7 @@ static void linphone_vcard_phone_numbers_and_sip_addresses(void) { BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(sip_addresses), 0, unsigned int, "%u"); BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(phone_numbers), 2, unsigned int, "%u"); - if (phone_numbers) bctbx_list_free_with_data(phone_numbers, ms_free); + if (phone_numbers) bctbx_list_free_with_data(phone_numbers, (bctbx_list_free_func)bctbx_free); addr = linphone_address_new("sip:sylvain@sip.linphone.org"); linphone_friend_add_address(lf, addr); @@ -190,12 +190,12 @@ static void linphone_vcard_phone_numbers_and_sip_addresses(void) { linphone_friend_remove_phone_number(lf, "0952636505"); phone_numbers = linphone_friend_get_phone_numbers(lf); BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(phone_numbers), 1, unsigned int, "%u"); - if (phone_numbers) bctbx_list_free_with_data(phone_numbers, ms_free); + if (phone_numbers) bctbx_list_free_with_data(phone_numbers, (bctbx_list_free_func)bctbx_free); linphone_friend_remove_phone_number(lf, "0476010203"); phone_numbers = linphone_friend_get_phone_numbers(lf); BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(phone_numbers), 0, unsigned int, "%u"); - if (phone_numbers) bctbx_list_free_with_data(phone_numbers, ms_free); + if (phone_numbers) bctbx_list_free_with_data(phone_numbers, (bctbx_list_free_func)bctbx_free); linphone_friend_edit(lf); linphone_friend_remove_address(lf, addr); @@ -206,7 +206,7 @@ static void linphone_vcard_phone_numbers_and_sip_addresses(void) { linphone_friend_add_phone_number(lf, "+33952636505"); phone_numbers = linphone_friend_get_phone_numbers(lf); BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(phone_numbers), 1, unsigned int, "%u"); - if (phone_numbers) bctbx_list_free_with_data(phone_numbers, ms_free); + if (phone_numbers) bctbx_list_free_with_data(phone_numbers, (bctbx_list_free_func)bctbx_free); linphone_address_unref(addr); linphone_friend_unref(lf);