From 8f5762219e91648f8021ca14c3a7095c865354e2 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Fri, 22 Dec 2023 08:19:47 -0600 Subject: [PATCH] application/windows: Guard from NULL dereference finding conversation * Happens from the native matrix plugin on a large account --- application/windows/MainWindow.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/application/windows/MainWindow.cpp b/application/windows/MainWindow.cpp index 02e1149..ab41e8e 100644 --- a/application/windows/MainWindow.cpp +++ b/application/windows/MainWindow.cpp @@ -23,6 +23,8 @@ #include #include +#include + #include "AccountDialog.h" #include "AccountsWindow.h" #include "AppMessages.h" @@ -683,7 +685,12 @@ ConversationItem* MainWindow::_EnsureConversationItem(BMessage* msg) { BString chat_id = msg->FindString("chat_id"); - Conversation* chat = Server::Get()->ConversationById(chat_id, msg->FindInt64("instance")); + int64 conversation_id = msg->FindInt64("instance"); + Conversation* chat = Server::Get()->ConversationById(chat_id, conversation_id); + if (chat == NULL) { + printf("error: Conversation %" B_PRId64 " in '%s' not found!\n", conversation_id, chat_id); + return NULL; + } _EnsureConversationView(chat);