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.
Description of changes:
Fixes a heap access violation found when implementing AppVerifier into the C++ V2 SDK CI. AppVerifier finds the issue at the end of running a sample and, according to the logs provided by AppVerifier, it is caused by an access violation caused by calling
CertFreeCertificateContext
inwindows/secure_channel_tls_handler.c
in thes_secure_channel_ctx_destroy
function.The issue seems to be that
CryptDestroyKey
frees the private key certificate context and so then whenCertFreeCertificateContext
is called to free the private key certificate context further down, it leads to the access violation since it is already free. Freeing the private certificate key store first, before the private key, causes the same issue when trying to free the private key.The fix implemented is to check if the private key was loaded from the private certificate store and, if it was, not delete the certificate store on shutdown.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.