[pim/kdepim-addons] kmail/editorsendcheckplugins/automaticaddcontacts: Fix potential crash
Laurent Montel <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit b90693460e01af6b396990aaa31e4fefba19e44f by Laurent Montel.
Committed on 16/08/2026 at 15:04.
Pushed by mlaurent into branch 'master'.
Fix potential crash
M +7 -1 kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.cpp
https://invent.kde.org/pim/kdepim-addons/-/commit/b90693460e01af6b396990aaa31e4fefba19e44f
diff --git a/kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.cpp b/kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.cpp
index d2f5d7f7c..71dc354df 100644
--- a/kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.cpp
+++ b/kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.cpp
@@ -72,7 +72,13 @@ void AutomaticAddContactsJob::slotSelectedCollectionFetched(KJob *job)
return;
}
const Akonadi::CollectionFetchJob *addressBookJob = qobject_cast<Akonadi::CollectionFetchJob *>(job);
- mCollection = addressBookJob->collections().at(0);
+ if (const Akonadi::Collection::List collections = addressBookJob->collections(); !collections.isEmpty()) {
+ mCollection = collections.at(0);
+ } else {
+ qCWarning(KMAIL_EDITOR_AUTOMATICADDCONTACTS_PLUGIN_LOG) << "Collection not found";
+ deleteLaterAndEmitSignal();
+ return;
+ }
addNextContact();
}