Prevent possible crash while reading contacts cursor.

fork-5.53.8
Greyson Parrelli 2022-03-30 16:17:15 -04:00
rodzic 42ccd638bd
commit 0278882c30
1 zmienionych plików z 3 dodań i 3 usunięć

Wyświetl plik

@ -579,11 +579,11 @@ object SystemContactsRepository {
} }
override fun hasNext(): Boolean { override fun hasNext(): Boolean {
return !cursor.isAfterLast return !cursor.isAfterLast && cursor.position >= 0
} }
override fun next(): ContactDetails { override fun next(): ContactDetails {
if (cursor.isAfterLast) { if (cursor.isAfterLast || cursor.position < 0) {
throw NoSuchElementException() throw NoSuchElementException()
} }
@ -591,7 +591,7 @@ object SystemContactsRepository {
val phoneDetails: List<ContactPhoneDetails> = readAllPhones(cursor, lookupKey) val phoneDetails: List<ContactPhoneDetails> = readAllPhones(cursor, lookupKey)
val structuredName: StructuredName? = readStructuredName(cursor, lookupKey) val structuredName: StructuredName? = readStructuredName(cursor, lookupKey)
while (!cursor.isAfterLast && cursor.getLookupKey() == lookupKey) { while (!cursor.isAfterLast && cursor.position >= 0 && cursor.getLookupKey() == lookupKey) {
cursor.moveToNext() cursor.moveToNext()
} }