From 44119b6437fd3dfe549f0b10894afcc8fc5b6ac6 Mon Sep 17 00:00:00 2001 From: Alex Hart Date: Mon, 28 Jun 2021 18:58:56 -0300 Subject: [PATCH] Do not crash if we try to access an item outside of the bounds of the conversation. --- .../securesms/conversation/ConversationAdapter.java | 8 +++++++- 1 file changed, 7 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 1662978b1f..3de00d869d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationAdapter.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationAdapter.java @@ -387,7 +387,13 @@ public class ConversationAdapter if (pagingController != null) { pagingController.onDataNeededAroundIndex(correctedPosition); } - return super.getItem(correctedPosition); + + if (correctedPosition < getItemCount()) { + return super.getItem(correctedPosition); + } else { + Log.d(TAG, "Could not access corrected position " + correctedPosition + " as it is out of bounds."); + return null; + } } }