Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17647a6f authored by Vincent Breitmoser's avatar Vincent Breitmoser
Browse files

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

parent 2279526e
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -554,8 +554,12 @@ public class MessageCryptoHelper {
    }

    private void onCryptoOperationCanceled() {
        // 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;
        if (currentCryptoPart != null) {
            partsToDecryptOrVerify.removeFirst();
            currentCryptoPart = null;
        } else {
            Log.e(K9.LOG_TAG, "Got to onCryptoFinished() with no part in processing!", new Throwable());
        }
        decryptOrVerifyNextPart();
    }