diff --git a/src/crypto/crypto_aes.cc b/src/crypto/crypto_aes.cc index fa619696ffd5b2..1d601eadfe71e8 100644 --- a/src/crypto/crypto_aes.cc +++ b/src/crypto/crypto_aes.cc @@ -48,7 +48,9 @@ WebCryptoCipherStatus AES_Cipher(Environment* env, CHECK_EQ(key_data.GetKeyType(), kKeyTypeSecret); auto ctx = CipherCtxPointer::New(); - CHECK(ctx); + if (!ctx) { + return WebCryptoCipherStatus::FAILED; + } if (params.cipher.isWrapMode()) { ctx.setAllowWrap(); diff --git a/src/crypto/crypto_cipher.cc b/src/crypto/crypto_cipher.cc index 638dda0ad10593..8d93e845322f28 100644 --- a/src/crypto/crypto_cipher.cc +++ b/src/crypto/crypto_cipher.cc @@ -338,7 +338,11 @@ void CipherBase::CommonInit(const char* cipher_type, MarkPopErrorOnReturn mark_pop_error_on_return; CHECK(!ctx_); ctx_ = CipherCtxPointer::New(); - CHECK(ctx_); + if (!ctx_) { + return ThrowCryptoError(env(), + mark_pop_error_on_return.peekError(), + "EVP_CIPHER_CTX_new"); + } if (cipher.isWrapMode()) { ctx_.setAllowWrap();