Title: [C++] more memory leaks in windows WinCAPICryptoXXXX files

Some more potential memory leaks in the following files .. I have not tested all of them

\xml-security\c\src\enc\WinCAPI\WinCAPICryptoHashHMAC.cpp(211):    HCRYPTHASH h;
\xml-security\c\src\enc\WinCAPI\WinCAPICryptoHashHMAC.cpp(339): HCRYPTHASH h;
\xml-security\c\src\enc\WinCAPI\WinCAPICryptoKeyDSA.cpp(348):   HCRYPTHASH h;
\xml-security\c\src\enc\WinCAPI\WinCAPICryptoKeyDSA.cpp(422):   HCRYPTHASH h;
\xml-security\c\src\enc\WinCAPI\WinCAPICryptoKeyRSA.cpp(300):   HCRYPTHASH h;
\xml-security\c\src\enc\WinCAPI\WinCAPICryptoKeyRSA.cpp(369):   HCRYPTHASH h;

It looks like these local objects never get freed by CryptDestroyHash().. on failure or success!

There is a wrapper "class" WinCAPICryptoHash, but I don’t think it was intended for the purpose of resource management.  With some simple changes it could do the job.  It looks like a resource wrapper is the best option, as many of the fn()'s that use the HCRYPTHASH can terminate early by throw'ing errors.

Hope this helps

Steve






Reply via email to