Fixed memory leak and return value check issue.
This commit is contained in:
parent
ed0024d11b
commit
aa11a6c89c
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user