From a9359653908f5c2ee33f2ee7079a20e9844112d8 Mon Sep 17 00:00:00 2001 From: etenie <99820286+vxtk@users.noreply.github.com> Date: Thu, 27 Nov 2025 16:42:17 +0100 Subject: [PATCH] Fix crash in notifyTwitchChannelOffline when snapshot is empty (#6604) Reviewed-by: Rasmus Karlsson --- CHANGELOG.md | 2 +- src/controllers/notifications/NotificationController.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e263cde5..1fdf30bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,7 +51,7 @@ - Dev: Mock headers are now added as a header set if supported by CMake. (#6561) - Dev: Set settings directory to temporary one used in tests. (#6584) - Dev: Check Lua unwinding and version in tests. (#6586) -- Dev: Added method to get the last N messages of a channel. (#6602) +- Dev: Added method to get the last N messages of a channel. (#6602, #6604) ## 2.5.4 diff --git a/src/controllers/notifications/NotificationController.cpp b/src/controllers/notifications/NotificationController.cpp index 333da102..5b2ad094 100644 --- a/src/controllers/notifications/NotificationController.cpp +++ b/src/controllers/notifications/NotificationController.cpp @@ -156,6 +156,13 @@ void NotificationController::notifyTwitchChannelOffline(const QString &id) const // "delete" old 'CHANNEL is live' message const LimitedQueueSnapshot snapshot = getApp()->getTwitch()->getLiveChannel()->getMessageSnapshot(200); + + // Guard against empty snapshot to prevent underflow and invalid access + if (snapshot.size() == 0) + { + return; + } + for (size_t i = snapshot.size() - 1; i >= 0; --i) { const auto &s = snapshot[i];