Fixed memory leak and return value check issue.

This commit is contained in:
Armin Novak 2017-03-28 17:56:44 +02:00
parent ed0024d11b
commit aa11a6c89c

View File

@ -44,7 +44,7 @@ int TestCryptoCertEnumCertificatesInStore(int argc, char* argv[])
while ((pCertContext = CertEnumCertificatesInStore(hCertStore, pCertContext)))
{
status = CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, NULL, 0);
if (status)
if (status == 0)
return -1;
pszNameString = (LPTSTR) malloc(status * sizeof(TCHAR));
@ -55,11 +55,16 @@ int TestCryptoCertEnumCertificatesInStore(int argc, char* argv[])
}
status = CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, pszNameString, status);
if (status)
if (status == 0)
{
free (pszNameString);
return -1;
}
_tprintf(_T("Certificate #%d: %s\n"), index++, pszNameString);
free(pszNameString);
#ifdef WITH_CRYPTUI
CryptUIDlgViewContext(CERT_STORE_CERTIFICATE_CONTEXT, pCertContext, NULL, NULL, 0, NULL);
#endif