diff --git a/dlls/crypt32/main.c b/dlls/crypt32/main.c index fa90ee05726..922dd1955a7 100644 --- a/dlls/crypt32/main.c +++ b/dlls/crypt32/main.c @@ -59,8 +59,16 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved) HCRYPTPROV CRYPT_GetDefaultProvider(void) { 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; }