From cab4e620e8f0ef54b913cd4d2d07d8636aa0e5e3 Mon Sep 17 00:00:00 2001 From: XadillaX Date: Thu, 3 Jun 2021 14:27:32 +0800 Subject: [PATCH] src,crypto: fix 0-length output crash in webcrypto Refs: https://github.com/nodejs/node/issues/38883 --- src/crypto/crypto_cipher.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crypto/crypto_cipher.h b/src/crypto/crypto_cipher.h index c8dd3e48f718fd..05561808010f20 100644 --- a/src/crypto/crypto_cipher.h +++ b/src/crypto/crypto_cipher.h @@ -249,7 +249,7 @@ class CipherJob final : public CryptoJob { v8::Local* result) override { Environment* env = AsyncWrap::env(); CryptoErrorStore* errors = CryptoJob::errors(); - if (out_.size() > 0) { + if (out_.size() > 0 || (!out_.size() && errors->Empty())) { CHECK(errors->Empty()); *err = v8::Undefined(env->isolate()); *result = out_.ToArrayBuffer(env);