diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc index 652f6e0b12e..0a2e0eacab7 100644 --- a/src/crypto/crypto_util.cc +++ b/src/crypto/crypto_util.cc @@ -689,22 +689,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,