From 454c8db00d85f6c74dfeaea33fc3f24087d9f994 Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Sat, 22 Apr 2023 21:09:46 +0400
Subject: [PATCH] Fix crash in empty topics message sending.

---
 Telegram/SourceFiles/data/data_forum_topic.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Telegram/SourceFiles/data/data_forum_topic.cpp b/Telegram/SourceFiles/data/data_forum_topic.cpp
index 5925f303d..7b5391a19 100644
--- a/Telegram/SourceFiles/data/data_forum_topic.cpp
+++ b/Telegram/SourceFiles/data/data_forum_topic.cpp
@@ -767,6 +767,7 @@ void ForumTopic::maybeSetLastMessage(not_null<HistoryItem*> item) {
 	Expects(item->topicRootId() == _rootId);
 
 	if (!_lastMessage
+		|| !(*_lastMessage)
 		|| ((*_lastMessage)->date() < item->date())
 		|| ((*_lastMessage)->date() == item->date()
 			&& (*_lastMessage)->id < item->id)) {