From fed919771698932895fb81dbb89b88188b3e8fe8 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 9 Nov 2024 18:04:54 -0500 Subject: [PATCH] Stop being able to crash NeoChat by pressing a button repeatedly If you spam click the "Close link preview" button, it's possible to crash NeoChat. This is because the index check is wrong for the array size. It's possible to even do this due to a bug causing the removal to be reflected visually too slowly, that's fixed in the next commit. (cherry picked from commit 253f891c5ad5e5578010ce395ca739a9169d4aa6) --- src/models/messagecontentmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/messagecontentmodel.cpp b/src/models/messagecontentmodel.cpp index 6edd05569..e6e415f56 100644 --- a/src/models/messagecontentmodel.cpp +++ b/src/models/messagecontentmodel.cpp @@ -635,7 +635,7 @@ QList MessageContentModel::addLinkPreviews(QList m_components.size()) { + if (row < 0 || row >= m_components.size()) { qWarning() << "closeLinkPreview() called with row" << row << "which does not exist. m_components.size() =" << m_components.size(); return; }