[network/kio-extras] recentlyused: recentlyused: do not crash on an empty item list
Méven Car <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 9cba15fbe2d6fe1ab8123d163b42419969fac26a by Méven Car.
Committed on 10/08/2026 at 10:20.
Pushed by meven into branch 'master'.
recentlyused: do not crash on an empty item list
ForgetFileItemAction::actions() read fileItems.first().url() before
checking the list was non-empty. A KFileItemAction plugin can be invoked
with an empty selection, for example a context menu opened with nothing
selected, and first() on an empty list is undefined behaviour, so url()
dereferenced an invalid KFileItem and crashed.
Return no actions when the item list is empty.
M +3 -0 recentlyused/forgetfileitemaction.cpp
https://invent.kde.org/network/kio-extras/-/commit/9cba15fbe2d6fe1ab8123d163b42419969fac26a
diff --git a/recentlyused/forgetfileitemaction.cpp b/recentlyused/forgetfileitemaction.cpp
index 7c9322742..a5d2d9629 100644
--- a/recentlyused/forgetfileitemaction.cpp
+++ b/recentlyused/forgetfileitemaction.cpp
@@ -26,6 +26,9 @@ QList<QAction *> ForgetFileItemAction::actions(const KFileItemListProperties &fi
{
Q_UNUSED(parentWidget)
+ if (fileItemInfos.items().isEmpty()) {
+ return {};
+ }
const KFileItemList &fileItems = fileItemInfos.items();
const auto url = fileItems.first().url();