Merge pull request #6830 from thundernest/fix_MessageList_crash

MessageList: Don't crash when being launched with invalid EXTRA_SEARCH value
This commit is contained in:
cketti 2023-04-20 16:01:52 +02:00 committed by GitHub
commit df9abbd678
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -355,6 +355,8 @@ public class LocalSearch implements SearchSpecification {
mManualSearch = (in.readByte() == 1);
mAccountUuids.addAll(in.createStringArrayList());
mConditions = in.readParcelable(LocalSearch.class.getClassLoader());
mLeafSet = (mConditions == null) ? null : mConditions.getLeafSet();
if (mConditions != null) {
mLeafSet = mConditions.getLeafSet();
}
}
}

View file

@ -465,7 +465,7 @@ open class MessageList :
val messageReference = MessageReference.parse(messageReferenceString)
if (messageReference != null) {
val search = if (intent.hasExtra(EXTRA_SEARCH)) {
val search = if (intent.hasByteArrayExtra(EXTRA_SEARCH)) {
ParcelableUtil.unmarshall(intent.getByteArrayExtra(EXTRA_SEARCH), LocalSearch.CREATOR)
} else {
messageReference.toLocalSearch()
@ -477,7 +477,7 @@ open class MessageList :
messageViewOnly = intent.getBooleanExtra(EXTRA_MESSAGE_VIEW_ONLY, false),
)
}
} else if (intent.hasExtra(EXTRA_SEARCH)) {
} else if (intent.hasByteArrayExtra(EXTRA_SEARCH)) {
// regular LocalSearch object was passed
val search = ParcelableUtil.unmarshall(intent.getByteArrayExtra(EXTRA_SEARCH), LocalSearch.CREATOR)
val noThreading = intent.getBooleanExtra(EXTRA_NO_THREADING, false)
@ -1554,3 +1554,7 @@ open class MessageList :
}
}
}
private fun Intent.hasByteArrayExtra(name: String): Boolean {
return getByteArrayExtra(name) != null
}