don't crash in onCryptoOperationCancelled if no part is being processed

This commit is contained in:
Vincent Breitmoser 2016-12-28 17:40:20 +01:00
parent 2279526e0d
commit 17647a6fac

View file

@ -554,8 +554,12 @@ public class MessageCryptoHelper {
}
private void onCryptoOperationCanceled() {
CryptoResultAnnotation errorPart = CryptoResultAnnotation.createOpenPgpCanceledAnnotation();
addCryptoResultAnnotationToMessage(errorPart);
// there are weird states that get us here when we're not actually processing any part. just skip in that case
// see https://github.com/k9mail/k-9/issues/1878
if (currentCryptoPart != null) {
CryptoResultAnnotation errorPart = CryptoResultAnnotation.createOpenPgpCanceledAnnotation();
addCryptoResultAnnotationToMessage(errorPart);
}
onCryptoFinished();
}
@ -579,8 +583,12 @@ public class MessageCryptoHelper {
}
private void onCryptoFinished() {
currentCryptoPart = null;
partsToDecryptOrVerify.removeFirst();
if (currentCryptoPart != null) {
partsToDecryptOrVerify.removeFirst();
currentCryptoPart = null;
} else {
Log.e(K9.LOG_TAG, "Got to onCryptoFinished() with no part in processing!", new Throwable());
}
decryptOrVerifyNextPart();
}