Avoid possibility of walking outside a contact cursor.

This commit is contained in:
Greyson Parrelli
2021-03-13 11:50:10 -05:00
parent b4266b8575
commit ec07e4b233

View File

@@ -334,7 +334,7 @@ public class DirectoryHelper {
Log.w(TAG, "Ignoring unexpected mime type: " + mimeType);
}
while (getLookupKey(cursor).equals(lookupKey) && isPhoneMimeType(getMimeType(cursor))) {
while (!cursor.isAfterLast() && getLookupKey(cursor).equals(lookupKey) && isPhoneMimeType(getMimeType(cursor))) {
String number = CursorUtil.requireString(cursor, ContactsContract.CommonDataKinds.Phone.NUMBER);
if (isValidContactNumber(number)) {
@@ -359,7 +359,7 @@ public class DirectoryHelper {
cursor.moveToNext();
}
if (getLookupKey(cursor).equals(lookupKey)) {
if (!cursor.isAfterLast() && getLookupKey(cursor).equals(lookupKey)) {
if (isStructuredNameMimeType(getMimeType(cursor))) {
StructuredNameRecord.Builder builder = new StructuredNameRecord.Builder();