summaryrefslogtreecommitdiff
path: root/kde-frameworks/kidletime/files/kidletime-5.92.0-crashfix.patch
diff options
context:
space:
mode:
Diffstat (limited to 'kde-frameworks/kidletime/files/kidletime-5.92.0-crashfix.patch')
-rw-r--r--kde-frameworks/kidletime/files/kidletime-5.92.0-crashfix.patch41
1 files changed, 41 insertions, 0 deletions
diff --git a/kde-frameworks/kidletime/files/kidletime-5.92.0-crashfix.patch b/kde-frameworks/kidletime/files/kidletime-5.92.0-crashfix.patch
new file mode 100644
index 000000000000..93a016d76fd0
--- /dev/null
+++ b/kde-frameworks/kidletime/files/kidletime-5.92.0-crashfix.patch
@@ -0,0 +1,41 @@
+From cd5040684723b87c7ba5b7cc1b1a63402902a641 Mon Sep 17 00:00:00 2001
+From: Ada Christine <adachristine18@gmail.com>
+Date: Sun, 27 Mar 2022 01:29:09 +0000
+Subject: [PATCH] Fixed crash during KIdleTime::timeoutReached()
+
+timeoutReached() will cause a crash if an item is removed from associations
+during signal dispatch due to iterator invalidation. iterate over a
+const container of the assoication keys only triggering ones matching
+the current timeout value to avoid the crash and unnecessary copying
+
+BUG: 451946
+---
+ src/kidletime.cpp | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/kidletime.cpp b/src/kidletime.cpp
+index a58eaa6..0929285 100644
+--- a/src/kidletime.cpp
++++ b/src/kidletime.cpp
+@@ -288,13 +288,13 @@ void KIdleTimePrivate::timeoutReached(int msec)
+ {
+ Q_Q(KIdleTime);
+
+- for (auto it = associations.cbegin(); it != associations.cend(); ++it) {
+- if (it.value() == msec) {
++ const auto listKeys = associations.keys(msec);
++
++ for (const auto key : listKeys) {
+ #if KIDLETIME_BUILD_DEPRECATED_SINCE(5, 76)
+- Q_EMIT q->timeoutReached(it.key());
++ Q_EMIT q->timeoutReached(key);
+ #endif
+- Q_EMIT q->timeoutReached(it.key(), msec);
+- }
++ Q_EMIT q->timeoutReached(key, msec);
+ }
+ }
+
+--
+GitLab
+