EVP_CIPHERs in the ssl_cipher_methods table can be NULL if
they are not available. We shouldn't attempt to up-ref a
cipher if it is NULL.
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11426)
if (*enc == NULL)
return 0;
} else {
- if (!ssl_evp_cipher_up_ref(ctx->ssl_cipher_methods[i]))
+ const EVP_CIPHER *cipher = ctx->ssl_cipher_methods[i];
+
+ if (cipher == NULL
+ || !ssl_evp_cipher_up_ref(cipher))
return 0;
*enc = ctx->ssl_cipher_methods[i];
}