From cc8f4aa24f797f48b31cfdce220f5bc1d6585ae5 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 12 Apr 2019 17:06:33 +0400 Subject: [PATCH] Fix crash in history clear. --- Telegram/SourceFiles/history/history.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 1b7c63298f..89935fc5dd 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -2947,8 +2947,8 @@ void History::clear(ClearType type) { changeUnreadCount(-unreadCount()); if (type == ClearType::DeleteChat) { setLastMessage(nullptr); - } else { - if (_lastMessage && IsServerMsgId((*_lastMessage)->id)) { + } else if (_lastMessage && *_lastMessage) { + if (IsServerMsgId((*_lastMessage)->id)) { (*_lastMessage)->applyEditionToHistoryCleared(); } else { _lastMessage = std::nullopt;