Fix possible crash in livestream story destruction.

This commit is contained in:
John Preston
2026-05-25 17:56:53 +04:00
parent 12582da1b8
commit 3cb167b7e5
3 changed files with 19 additions and 0 deletions
@@ -433,6 +433,16 @@ void Session::clear() {
_shortcutMessages = nullptr;
_session->scheduledMessages().clear();
_session->sponsoredMessages().clear();
// Items are gone now, so HistoryMessageReply::resolvedStory raw
// pointers no longer linger. Tear stories down here so their
// shared_ptr<GroupCall> drops while Main::Session::_data still
// holds a live pointer to us; otherwise the GroupCall destructor
// would run inside ~Data::Session and find data() returning a
// null reference (the parent unique_ptr resets its stored pointer
// before invoking the deleter).
_stories->clear();
_dependentMessages.clear();
base::take(_messages);
base::take(_nonChannelMessages);