Serge Gautherie : advapi32: Use standard refcount in CRYPTPROV.

Alexandre Julliard julliard at winehq.org
Tue Mar 17 17:21:10 CDT 2020


Module: wine
Branch: master
Commit: 62df03af96822bda36aef398d00bf5998f490e90
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=62df03af96822bda36aef398d00bf5998f490e90

Author: Serge Gautherie <winehq-git_serge_180711 at gautherie.fr>
Date:   Tue Mar 17 14:48:17 2020 +0100

advapi32: Use standard refcount in CRYPTPROV.

Signed-off-by: Serge Gautherie <winehq-git_serge_180711 at gautherie.fr>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/advapi32/crypt.c | 5 ++---
 dlls/advapi32/crypt.h | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/dlls/advapi32/crypt.c b/dlls/advapi32/crypt.c
index 14acceb100..f49a4973d7 100644
--- a/dlls/advapi32/crypt.c
+++ b/dlls/advapi32/crypt.c
@@ -636,7 +636,7 @@ BOOL WINAPI CryptContextAddRef (HCRYPTPROV hProv, DWORD *pdwReserved, DWORD dwFl
 		return FALSE;
 	}
 
-	pProv->refcount++;
+	InterlockedIncrement(&pProv->refcount);
 	return TRUE;
 }
 
@@ -672,8 +672,7 @@ BOOL WINAPI CryptReleaseContext (HCRYPTPROV hProv, DWORD dwFlags)
 		return FALSE;
 	}
 
-	pProv->refcount--;
-	if (pProv->refcount <= 0) 
+	if (InterlockedDecrement(&pProv->refcount) == 0)
 	{
 		ret = pProv->pFuncs->pCPReleaseContext(pProv->hPrivate, dwFlags);
 		pProv->dwMagic = 0;
diff --git a/dlls/advapi32/crypt.h b/dlls/advapi32/crypt.h
index afee3e2e29..a4429642d2 100644
--- a/dlls/advapi32/crypt.h
+++ b/dlls/advapi32/crypt.h
@@ -63,7 +63,7 @@ typedef struct tagPROVFUNCS
 typedef struct tagCRYPTPROV
 {
 	DWORD dwMagic;
-	UINT refcount;
+	LONG refcount;
 	HMODULE hModule;
 	PPROVFUNCS pFuncs;
         HCRYPTPROV hPrivate;  /*CSP's handle - Should not be given to application under any circumstances!*/




More information about the wine-cvs mailing list