diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc index a804fe8dd071aa..805f8978b2ad1b 100644 --- a/src/crypto/crypto_util.cc +++ b/src/crypto/crypto_util.cc @@ -674,22 +674,21 @@ CryptoJobMode GetCryptoJobMode(v8::Local args) { } namespace { -// SecureBuffer uses openssl to allocate a Uint8Array using -// OPENSSL_secure_malloc. Because we do not yet actually -// make use of secure heap, this has the same semantics as +// SecureBuffer uses OPENSSL_secure_malloc to allocate a Uint8Array. +// Without --secure-heap, OpenSSL's secure heap is disabled, +// in which case this has the same semantics as // using OPENSSL_malloc. However, if the secure heap is // initialized, SecureBuffer will automatically use it. void SecureBuffer(const FunctionCallbackInfo& args) { CHECK(args[0]->IsUint32()); Environment* env = Environment::GetCurrent(args); uint32_t len = args[0].As()->Value(); - char* data = static_cast(OPENSSL_secure_malloc(len)); + void* data = OPENSSL_secure_zalloc(len); if (data == nullptr) { // There's no memory available for the allocation. // Return nothing. return; } - memset(data, 0, len); std::shared_ptr store = ArrayBuffer::NewBackingStore( data,