From 8d6094ecd62e47ec69d3399e0344109ef0a67295 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Fri, 18 Oct 2019 15:16:41 +1100 Subject: [PATCH] Fix crash when viewing media --- .../thoughtcrime/securesms/database/AttachmentDatabase.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/database/AttachmentDatabase.java b/src/org/thoughtcrime/securesms/database/AttachmentDatabase.java index 2beec07057..918ffbd9d1 100644 --- a/src/org/thoughtcrime/securesms/database/AttachmentDatabase.java +++ b/src/org/thoughtcrime/securesms/database/AttachmentDatabase.java @@ -659,6 +659,7 @@ public class AttachmentDatabase extends Database { return result; } else { + int urlIndex = cursor.getColumnIndex(URL); return Collections.singletonList(new DatabaseAttachment(new AttachmentId(cursor.getLong(cursor.getColumnIndexOrThrow(ROW_ID)), cursor.getLong(cursor.getColumnIndexOrThrow(UNIQUE_ID))), cursor.getLong(cursor.getColumnIndexOrThrow(MMS_ID)), @@ -683,7 +684,7 @@ public class AttachmentDatabase extends Database { cursor.getString(cursor.getColumnIndexOrThrow(STICKER_PACK_KEY)), cursor.getInt(cursor.getColumnIndexOrThrow(STICKER_ID))) : null, - cursor.getString(cursor.getColumnIndexOrThrow(URL)))); + urlIndex > 0 ? cursor.getString(urlIndex) : "")); } } catch (JSONException e) { throw new AssertionError(e);