From 16498be4a2c4b08b9763f21de4bc5670c89db4ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 8 Jul 2014 04:24:27 +0200 Subject: [PATCH] Fix nullpointer in API, fix #693 --- .../keychain/remote/OpenPgpService.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index 17c277026..62d6b5ad6 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -53,6 +53,12 @@ import java.util.Set; public class OpenPgpService extends RemoteService { + static final String[] KEYRING_PROJECTION = + new String[]{ + KeyRings._ID, + KeyRings.MASTER_KEY_ID, + }; + /** * Search database for key ids based on emails. * @@ -70,7 +76,7 @@ public class OpenPgpService extends RemoteService { for (String email : encryptionUserIds) { Uri uri = KeyRings.buildUnifiedKeyRingsFindByEmailUri(email); - Cursor cursor = getContentResolver().query(uri, null, null, null, null); + Cursor cursor = getContentResolver().query(uri, KEYRING_PROJECTION, null, null, null); try { if (cursor != null && cursor.moveToFirst()) { long id = cursor.getLong(cursor.getColumnIndex(KeyRings.MASTER_KEY_ID));