Commit 75e614ba authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Prevent crashing from null AlarmNotification pointer

This MR adds a check for null pointers when iterating over the notification hash which should prevent crashes from trying to access a nullptr
parent 24f3853f
Pipeline #197554 passed with stage
in 3 minutes and 36 seconds
......@@ -252,16 +252,32 @@ void KalendarAlarmClient::checkAlarms()
}
}
QVector<QString> nullAlarmNotificationIds;
// execute or update active alarms
for (auto it = m_notifications.begin(); it != m_notifications.end(); ++it) {
if (it.value()->remindAt() <= mLastChecked) {
const auto incidence = mCalendar->incidence(it.value()->uid());
const auto notification = it.value();
// Protect against null ptr
if(!notification) {
qCDebug(Log) << "Found null active alarm with id: " << it.key() << "Skipping.";
nullAlarmNotificationIds.append(it.key());
continue;
}
if (notification->remindAt() <= mLastChecked) {
const auto incidence = mCalendar->incidence(notification->uid());
if (incidence) { // can still be null when we get here during the early stages of loading/restoring
it.value()->send(this, incidence);
notification->send(this, incidence);
}
}
}
// Remove the null alarm notification ptrs from our notifications
for(const auto &nullAlarmId : nullAlarmNotificationIds) {
m_notifications.remove(nullAlarmId);
}
saveLastCheckTime();
// schedule next check for the beginning of the next minute
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment