Closed ergl closed 3 years ago
On second thought, I guess there's a potential memory leak on 0.9.0 since the context won't be freed even if the Digest class itself is GC'd
@ergl let me know if you disagree with any of the labels I added to this issue.
No, it's fine. I'll think about the issue and submit a patch after I'm done with the FFI PR.
In
Digest.final()
, after finishing with the context, it is cleaned up:https://github.com/ponylang/crypto/blob/e58e4ab5ffe7adeb9e25ead3544fb666d51418fc/crypto/digest.pony#L157-L161
Depending on the SSL version, it will either use
*_free
or*_cleanup
, however, those two functions are not equivalent (from the docs):This means that on OpenSSL 1.1.x, the code is freeing
_ctx
, while on OpenSSL 0.9.0 it is merely resetting it to a state where it can be reused again.Currently the Digest class can't be reused (calling
append
after callingfinal
raises an error). Either of the two approaches could work here, but I guess we should use the same behaviour for cleaning up in both versions of OpenSSL.