From 815a988587b5d4c62d33b3634a209db4bb058389 Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Wed, 24 Mar 2021 19:55:43 -0400 Subject: [PATCH] Prevent crash when trying to save conversation viewing position. --- .../securesms/conversation/ConversationAdapter.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationAdapter.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationAdapter.java index 19b6a6c449..2a885f5517 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationAdapter.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationAdapter.java @@ -595,7 +595,12 @@ public class ConversationAdapter } public @Nullable ConversationMessage getLastVisibleConversationMessage(int position) { - return getItem(position - ((hasFooter() && position == getItemCount() - 1) ? 1 : 0)); + try { + return getItem(position - ((hasFooter() && position == getItemCount() - 1) ? 1 : 0)); + } catch (IndexOutOfBoundsException e) { + Log.w(TAG, "Race condition changed size of conversation", e); + return null; + } } public void setMessageRequestAccepted(boolean messageRequestAccepted) {