From f39a03fe1377592463ca5bccefff82271a414392 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Thu, 15 Oct 2020 17:45:13 +0200 Subject: [PATCH] [plugins/notifications] Prevent crash when default notification action is invoked. When the notification's default action is activated, i.e. the notification is clicked, activated with index 0 is emitted. This will lead to a crash since m_actions[-1] will be accessed. This does not happen on Plasma since we don't specify that we have a default action and thus the notification isn't clickable. However on LXDE the notification is clickable regardless and we get the according signal. This arguably works around a bug in LXDE, but given that the workaround is cheap and other systems may behave this way too I think it's reasonable to do this. BUG: 427717 --- plugins/notifications/notification.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/notifications/notification.cpp b/plugins/notifications/notification.cpp index e5206b9e6..261e071d7 100644 --- a/plugins/notifications/notification.cpp +++ b/plugins/notifications/notification.cpp @@ -49,6 +49,13 @@ Notification::Notification(const NetworkPacket& np, const Device* device, QObjec if(!m_requestReplyId.isEmpty() && actionIndex == 1) { return; } + + // index 0 is the default action. Some notification servers send this even though they shouldn't. + // https://bugs.kde.org/show_bug.cgi?id=427717 + if (actionIndex == 0) { + return; + } + // Notification action indices start at 1 Q_EMIT actionTriggered(m_internalId, m_actions[actionIndex - 1]); });