From 8003b09e3b05b768e077df1ebc91399eb0220285 Mon Sep 17 00:00:00 2001 From: Christophe Deschamps Date: Wed, 29 Jan 2025 17:12:14 +0100 Subject: [PATCH] Prevent crashes creating contacts with only phone number and no SIP address --- Linphone/model/search/MagicSearchModel.cpp | 4 ++-- Linphone/tool/Utils.cpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Linphone/model/search/MagicSearchModel.cpp b/Linphone/model/search/MagicSearchModel.cpp index d8cdbe41..11167be1 100644 --- a/Linphone/model/search/MagicSearchModel.cpp +++ b/Linphone/model/search/MagicSearchModel.cpp @@ -100,7 +100,7 @@ void MagicSearchModel::onSearchResultsReceived(const std::shared_ptr r) { - return r->getAddress()->weakEqual(result->getAddress()); + return r->getAddress() && r->getAddress()->weakEqual(result->getAddress()); }); if (resultIt == finalResults.end()) finalResults.push_back(result); else if (fList && fList->getDisplayName() == "app_friends") *resultIt = result; // replace if local friend @@ -142,5 +142,5 @@ void MagicSearchModel::updateFriendListWithFriend(const std::shared_ptraddFriend(linphoneFriend); - emit CoreModel::getInstance()->friendCreated(linphoneFriend); + emit CoreModel::getInstance() -> friendCreated(linphoneFriend); } diff --git a/Linphone/tool/Utils.cpp b/Linphone/tool/Utils.cpp index 2852a21b..efdbd427 100644 --- a/Linphone/tool/Utils.cpp +++ b/Linphone/tool/Utils.cpp @@ -364,7 +364,8 @@ VariantObject *Utils::findAvatarByAddress(const QString &address) { }); // Rebuild avatar if needed auto updateValue = [data, address](const std::shared_ptr &f) -> void { - if (f && f->getAddress()->weakEqual(ToolModel::interpretUrl(address))) data->invokeRequestValue(); + if (f && f->getAddress() && f->getAddress()->weakEqual(ToolModel::interpretUrl(address))) + data->invokeRequestValue(); }; data->makeUpdateCond(CoreModel::getInstance().get(), &CoreModel::friendCreated, updateValue); data->makeUpdateCond(CoreModel::getInstance().get(), &CoreModel::friendRemoved, updateValue);