From 33daa21ad9c8e5e0e87b646fb06a09b2e431b045 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Tue, 19 Feb 2019 09:29:10 -0800 Subject: [PATCH] Guard against devices not supporting mandatory ContentProvider columns. The docs specify that this column is supposed to be present, but a crash says it wasn't, so alas, here in goes the check. --- src/org/thoughtcrime/securesms/mediasend/MediaRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/mediasend/MediaRepository.java b/src/org/thoughtcrime/securesms/mediasend/MediaRepository.java index 7e8e1662fa..e095223073 100644 --- a/src/org/thoughtcrime/securesms/mediasend/MediaRepository.java +++ b/src/org/thoughtcrime/securesms/mediasend/MediaRepository.java @@ -267,7 +267,7 @@ class MediaRepository { if (size <= 0) { try (Cursor cursor = context.getContentResolver().query(media.getUri(), null, null, null, null)) { - if (cursor != null && cursor.moveToFirst()) { + if (cursor != null && cursor.moveToFirst() && cursor.getColumnIndex(OpenableColumns.SIZE) >= 0) { size = cursor.getLong(cursor.getColumnIndexOrThrow(OpenableColumns.SIZE)); } }