Partial fix of t/local/31_rsa_generate_key.t memory leaks #499
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If you build perl and Net::SSLleay with Address Sanitizer and run tests,
t/local/31_rsa_generate_key.twill fail with some Memory Leak error messages. There are two parts of this problem.Second part: You should explicitly free RSA structure created with
RSA_generate_key, when it is no longer in use this will prevent unnecessary memory leaks. This patch solves this problem.First part: Test that checks failure with not-proper callback scalar value
also causes memory leak.
As far as I can get this happens because
RSA_generate_keyfromSSLeay.xsallocate something, then callsRSA_generate_key_exwithssleay_RSA_generate_key_cb_invokeas a callback. Andssleay_RSA_generate_key_cb_invokecallscount = call_sv( cb->func, G_VOID|G_DISCARD );that throws an exception ifcb->funcis not a function. Thus we do not free what have been allocated inRSA_generate_keyand go straight todies_likeexception catcher.I guess best solution would be to catch that exception in
RSA_generate_key, free the staff, and then rethrow it. Because there can be any exception in a call back, even user generated. But such trick is beyond my power for now.So this patch will fix only
RSA_freerelated things.PS You can find instruction on how to build perl in this module using ASan in #469
PPS please refer me as NATARAJ (Nikolay Shaplov) if you ever would like to mention me anywhere...