Juan Lang : crypt32: Use a structure to hold function address handle.
Alexandre Julliard
julliard at winehq.org
Thu Oct 18 07:59:36 CDT 2007
Module: wine
Branch: master
Commit: 6b390b4009710bb8bc74578bf3270ce02b70359b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6b390b4009710bb8bc74578bf3270ce02b70359b
Author: Juan Lang <juan.lang at gmail.com>
Date: Wed Oct 17 09:30:33 2007 -0700
crypt32: Use a structure to hold function address handle.
---
dlls/crypt32/oid.c | 29 ++++++++++++++++++++++++++---
1 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/dlls/crypt32/oid.c b/dlls/crypt32/oid.c
index 1e2de95..46c9b05 100644
--- a/dlls/crypt32/oid.c
+++ b/dlls/crypt32/oid.c
@@ -275,6 +275,11 @@ BOOL WINAPI CryptInstallOIDFunctionAddress(HMODULE hModule,
return ret;
}
+struct FuncAddr
+{
+ HMODULE lib;
+};
+
static BOOL CRYPT_GetFuncFromReg(DWORD dwEncodingType, LPCSTR pszOID,
LPCSTR szFuncName, LPVOID *ppvFuncAddr, HCRYPTOIDFUNCADDR *phFuncAddr)
{
@@ -322,8 +327,20 @@ static BOOL CRYPT_GetFuncFromReg(DWORD dwEncodingType, LPCSTR pszOID,
*ppvFuncAddr = GetProcAddress(lib, funcName);
if (*ppvFuncAddr)
{
- *phFuncAddr = (HCRYPTOIDFUNCADDR)lib;
- ret = TRUE;
+ struct FuncAddr *addr =
+ CryptMemAlloc(sizeof(struct FuncAddr));
+
+ if (addr)
+ {
+ addr->lib = lib;
+ *phFuncAddr = addr;
+ ret = TRUE;
+ }
+ else
+ {
+ *phFuncAddr = NULL;
+ FreeLibrary(lib);
+ }
}
else
{
@@ -409,7 +426,13 @@ BOOL WINAPI CryptFreeOIDFunctionAddress(HCRYPTOIDFUNCADDR hFuncAddr,
* and only unload it if it can be unloaded. Also need to implement ref
* counting on the functions.
*/
- FreeLibrary((HMODULE)hFuncAddr);
+ if (hFuncAddr)
+ {
+ struct FuncAddr *addr = (struct FuncAddr *)hFuncAddr;
+
+ FreeLibrary(addr->lib);
+ CryptMemFree(addr);
+ }
return TRUE;
}
More information about the wine-cvs
mailing list