crypt32: Fix race condition in loading default provider.

This commit is contained in:
Juan Lang 2008-01-14 11:15:35 -08:00 committed by Alexandre Julliard
parent 027236b04f
commit 5c8aa89163

View File

@ -59,8 +59,16 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
HCRYPTPROV CRYPT_GetDefaultProvider(void) HCRYPTPROV CRYPT_GetDefaultProvider(void)
{ {
if (!hDefProv) if (!hDefProv)
CryptAcquireContextW(&hDefProv, NULL, MS_ENHANCED_PROV_W, {
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); HCRYPTPROV prov;
CryptAcquireContextW(&prov, NULL, MS_ENHANCED_PROV_W, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT);
InterlockedCompareExchangePointer((PVOID *)&hDefProv, (PVOID)prov,
NULL);
if (hDefProv != prov)
CryptReleaseContext(prov, 0);
}
return hDefProv; return hDefProv;
} }