From 6a43107bb27d175454c495e9d0cef03fb30ac11f Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 4 Jun 2025 16:52:44 +0400 Subject: [PATCH] Fix possible crash in subsection tabs. --- .../history/view/history_view_subsection_tabs.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_subsection_tabs.cpp b/Telegram/SourceFiles/history/view/history_view_subsection_tabs.cpp index 5757d7b89e..4d9f888d25 100644 --- a/Telegram/SourceFiles/history/view/history_view_subsection_tabs.cpp +++ b/Telegram/SourceFiles/history/view/history_view_subsection_tabs.cpp @@ -341,11 +341,15 @@ void SubsectionTabs::setupSlider( scrollSavingIndex = -1; for (auto index = 0; index != count; ++index) { const auto thread = _sectionsSlice[index].thread; - if (ranges::contains(_slice, thread, &Item::thread)) { + const auto i = ranges::find( + _slice, + thread, + &Item::thread); + if (i != end(_slice)) { scrollSavingThread = thread; scrollSavingShift = scrollValue - slider->lookupSectionPosition(index); - scrollSavingIndex = index; + scrollSavingIndex = int(i - begin(_slice)); break; } }