Skip to content

Commit

Permalink
Use OPENSSL_clear_free()
Browse files Browse the repository at this point in the history
  • Loading branch information
RaisinTen committed Sep 18, 2021
1 parent 3cf6a7b commit 041bb29
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/crypto/crypto_dh.cc
Expand Up @@ -578,13 +578,16 @@ Local<Value> StatelessDiffieHellman(
&out_size))
return Undefined(env->isolate());

void* hint = reinterpret_cast<void*>(static_cast<uintptr_t>(out_size));
return Buffer::New(env,
buf,
out_size,
[](char* data, void* hint) {
OPENSSL_free(data);
size_t out_size = static_cast<size_t>(
reinterpret_cast<uintptr_t>(hint));
OPENSSL_clear_free(data, out_size);
},
nullptr).FromMaybe(Local<Object>());
hint).FromMaybe(Local<Object>());
}

// The version of StatelessDiffieHellman that returns a Buffer
Expand Down

0 comments on commit 041bb29

Please sign in to comment.