crypt32: Fix leaked chains creating the root store.

This commit is contained in:
Juan Lang 2007-11-01 09:31:43 -07:00 committed by Alexandre Julliard
parent fc14728efc
commit e94ce8a0b2
1 changed files with 15 additions and 13 deletions

View File

@ -232,21 +232,22 @@ static const char *get_cert_common_name(PCCERT_CONTEXT cert)
static void check_and_store_certs(HCERTSTORE from, HCERTSTORE to) static void check_and_store_certs(HCERTSTORE from, HCERTSTORE to)
{ {
PCCERT_CONTEXT cert = NULL;
DWORD root_count = 0; DWORD root_count = 0;
CERT_CHAIN_ENGINE_CONFIG chainEngineConfig =
{ sizeof(chainEngineConfig), 0 };
HCERTCHAINENGINE engine;
TRACE("\n"); TRACE("\n");
do { CertDuplicateStore(to);
cert = CertEnumCertificatesInStore(from, cert); engine = CRYPT_CreateChainEngine(to, &chainEngineConfig);
if (cert) if (engine)
{ {
CERT_CHAIN_ENGINE_CONFIG chainEngineConfig = PCCERT_CONTEXT cert = NULL;
{ sizeof(chainEngineConfig), 0 };
HCERTCHAINENGINE engine = CRYPT_CreateChainEngine(to,
&chainEngineConfig);
if (engine) do {
cert = CertEnumCertificatesInStore(from, cert);
if (cert)
{ {
CERT_CHAIN_PARA chainPara = { sizeof(chainPara), { 0 } }; CERT_CHAIN_PARA chainPara = { sizeof(chainPara), { 0 } };
PCCERT_CHAIN_CONTEXT chain; PCCERT_CHAIN_CONTEXT chain;
@ -275,11 +276,12 @@ static void check_and_store_certs(HCERTSTORE from, HCERTSTORE to)
CERT_STORE_ADD_NEW, NULL)) CERT_STORE_ADD_NEW, NULL))
root_count++; root_count++;
} }
CertFreeCertificateChain(chain);
} }
CertFreeCertificateChainEngine(engine);
} }
} } while (cert);
} while (cert); CertFreeCertificateChainEngine(engine);
}
TRACE("Added %d root certificates\n", root_count); TRACE("Added %d root certificates\n", root_count);
} }