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

Commit 518f72ca authored by Steve Block's avatar Steve Block
Browse files

Fix SslError.getPrimaryError() to return -1 if the set of errors is empty

Also fix a couple of buggy asserts.

Bug: 5416594
Change-Id: I0e7e2548886af5fc0b8c20f70a3040d2c5bc68ea
parent 4198627a
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -198,7 +198,8 @@ public class SslError {

    /**
     * Gets the most severe SSL error in this object's set of errors.
     * @return The most severe SSL error.
     * Returns -1 if the set is empty.
     * @return The most severe SSL error, or -1 if the set is empty.
     */
    public int getPrimaryError() {
        if (mErrors != 0) {
@@ -208,9 +209,11 @@ public class SslError {
                    return error;
                }
            }
            // mErrors should never be set to an invalid value.
            assert false;
        }

        return 0;
        return -1;
    }

    /**
+2 −2
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ class SslErrorHandlerImpl extends SslErrorHandler {

        if (DebugFlags.SSL_ERROR_HANDLER) {
            assert host != null;
            assert primary != 0;
            assert primary != -1;
        }

        if (mSslPrefTable.containsKey(host) && primary <= mSslPrefTable.getInt(host)) {
@@ -260,7 +260,7 @@ class SslErrorHandlerImpl extends SslErrorHandler {

                if (DebugFlags.SSL_ERROR_HANDLER) {
                    assert host != null;
                    assert primary != 0;
                    assert primary != -1;
                }
                boolean hasKey = mSslPrefTable.containsKey(host);
                if (!hasKey || primary > mSslPrefTable.getInt(host)) {