kopia lustrzana https://github.com/ryukoposting/Signal-Android
Prevent possible crash while reading contacts cursor.
rodzic
42ccd638bd
commit
0278882c30
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue