There are several cases in the native code that call EVP_MD_CTX_init after EVP_MD_CTX_new
However, based on the OpenSSL documentation:
EVP_MD_CTX_new(): This function allocates, initializes, and returns a new EVP_MD_CTX structure. It is ready for immediate use.
EVP_MD_CTX_new already performs the necessary allocation and internal initialization.
Calling EVP_MD_CTX_init immediately after is redundant and, in some library versions, could lead to a minor memory leak if new had already allocated internal sub-structures.
Recommendation: Use EVP_MD_CTX_new() to allocate and EVP_MD_CTX_free() to clean up.
https://man.openbsd.org/OpenBSD-6.4/EVP_DigestInit.3#EVP_MD_CTX_init
EVP_MD_CTX_init() is a deprecated function to clear a digest context on the stack before use. Do not use it on a digest context returned from EVP_MD_CTX_new() or one one that was already used.
@jasonkatonica
There are several cases in the native code that call
EVP_MD_CTX_initafterEVP_MD_CTX_newHowever, based on the OpenSSL documentation:
EVP_MD_CTX_new(): This function allocates, initializes, and returns a newEVP_MD_CTXstructure. It is ready for immediate use.EVP_MD_CTX_newalready performs the necessary allocation and internal initialization.Calling
EVP_MD_CTX_initimmediately after is redundant and, in some library versions, could lead to a minor memory leak if new had already allocated internal sub-structures.Recommendation: Use
EVP_MD_CTX_new()to allocate andEVP_MD_CTX_free()to clean up.https://man.openbsd.org/OpenBSD-6.4/EVP_DigestInit.3#EVP_MD_CTX_init
@jasonkatonica