Skip to content

crypto: fix memory leak, reduce heap allocations, clean up

Fixes: nodejs#13917

Also of note:

The EVP_CIPHER can be reconstructed from the EVP_CIPHER_CTX instance, no need to store it separately.

This brought to light the somewhat dubious practice of accessing the EVP_CIPHER after the EVP_CIPHER_CTX instance had been destroyed.

It's mostly harmless due to the static nature of built-in EVP_CIPHER instances but it segfaults when the cipher is provided by an ENGINE and the ENGINE is unloaded because its reference count drops to zero.

I'll clean up the commit logs some more before landing.

CI: https://ci.nodejs.org/job/node-test-pull-request/9027/

Merge request reports

Loading