Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/crypto/crypto_aes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion src/crypto/crypto_chacha20_poly1305.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ WebCryptoCipherStatus ChaCha20Poly1305CipherTraits::DoCipher(
return WebCryptoCipherStatus::OK;
#else
auto ctx = CipherCtxPointer::New();
CHECK(ctx);
if (!ctx) {
return WebCryptoCipherStatus::FAILED;
}

const bool encrypt = cipher_mode == kWebCryptoCipherEncrypt;

Expand Down
10 changes: 9 additions & 1 deletion src/crypto/crypto_cipher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ void GetCipherInfo(const FunctionCallbackInfo<Value>& args) {
// If it is, then the getCipherInfo will succeed with the given
// values.
auto ctx = CipherCtxPointer::New();
if (!ctx) {
return THROW_ERR_CRYPTO_OPERATION_FAILED(
env, "Failed to allocate cipher context");
}

if (!ctx.init(cipher, true)) {
return;
}
Expand Down Expand Up @@ -338,7 +343,10 @@ void CipherBase::CommonInit(const char* cipher_type,
MarkPopErrorOnReturn mark_pop_error_on_return;
CHECK(!ctx_);
ctx_ = CipherCtxPointer::New();
CHECK(ctx_);
if (!ctx_) {
return THROW_ERR_CRYPTO_OPERATION_FAILED(
env(), "Failed to allocate cipher context");
}

if (cipher.isWrapMode()) {
ctx_.setAllowWrap();
Expand Down
Loading