diff --git a/src/crypto/crypto_dh.cc b/src/crypto/crypto_dh.cc index cacebcb360ab07..c5c726d9e491e4 100644 --- a/src/crypto/crypto_dh.cc +++ b/src/crypto/crypto_dh.cc @@ -578,13 +578,16 @@ Local StatelessDiffieHellman( &out_size)) return Undefined(env->isolate()); + void* hint = reinterpret_cast(static_cast(out_size)); return Buffer::New(env, buf, out_size, [](char* data, void* hint) { - OPENSSL_free(data); + size_t out_size = static_cast( + reinterpret_cast(hint)); + OPENSSL_clear_free(data, out_size); }, - nullptr).FromMaybe(Local()); + hint).FromMaybe(Local()); } // The version of StatelessDiffieHellman that returns a Buffer