From 02c3d74eb695520f475b294a410a2f898fbaea12 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Thu, 23 Feb 2023 23:45:36 +0100 Subject: [PATCH] Add support for `channelsToTreat` to be empty It's the case when providing a single channel in `channels.txt` for instance. --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 6257583..8605fb8 100644 --- a/main.cpp +++ b/main.cpp @@ -712,7 +712,7 @@ void markChannelAsRequiringTreatmentIfNeeded(unsigned short threadId, string cha if(channelsAlreadyTreated.find(channelId) == channelsAlreadyTreated.end() && channelsToTreatRev.find(channelId) == channelsToTreatRev.end()) { // It is unclear to me why `channelsToTreat.end()->first + 1` doesn't work here. - unsigned int channelsToTreatIndex = channelsToTreat.rbegin()->first + 1; + unsigned int channelsToTreatIndex = !channelsToTreat.empty() ? channelsToTreat.rbegin()->first + 1 : channelsAlreadyTreated.size(); channelsToTreat[channelsToTreatIndex] = channelId; channelsToTreatRev[channelId] = channelsToTreatIndex;