Hans Leidekker : dssenh: Don't store the algorithm handle for hashes.
Alexandre Julliard
julliard at winehq.org
Mon Oct 12 15:20:51 CDT 2020
Module: wine
Branch: master
Commit: b5e931d83c0518976c29ae7200250214e74ff02c
URL: https://source.winehq.org/git/wine.git/?a=commit;h=b5e931d83c0518976c29ae7200250214e74ff02c
Author: Hans Leidekker <hans at codeweavers.com>
Date: Mon Oct 12 16:11:08 2020 +0200
dssenh: Don't store the algorithm handle for hashes.
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dssenh/main.c | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/dlls/dssenh/main.c b/dlls/dssenh/main.c
index f02e04585a..e9b676e735 100644
--- a/dlls/dssenh/main.c
+++ b/dlls/dssenh/main.c
@@ -59,7 +59,6 @@ struct container
struct hash
{
DWORD magic;
- BCRYPT_ALG_HANDLE alg_handle;
BCRYPT_HASH_HANDLE handle;
DWORD len;
UCHAR value[64];
@@ -475,6 +474,7 @@ BOOL WINAPI CPExportKey( HCRYPTPROV hprov, HCRYPTKEY hkey, HCRYPTKEY hexpkey, DW
static struct hash *create_hash( ALG_ID algid )
{
struct hash *ret;
+ BCRYPT_ALG_HANDLE alg_handle;
const WCHAR *alg;
DWORD len;
@@ -492,24 +492,26 @@ static struct hash *create_hash( ALG_ID algid )
default:
FIXME( "unhandled algorithm %u\n", algid );
- return 0;
+ return NULL;
}
- if (!(ret = heap_alloc_zero( sizeof(*ret) ))) return 0;
+ if (!(ret = heap_alloc_zero( sizeof(*ret) ))) return NULL;
ret->magic = MAGIC_HASH;
ret->len = len;
- if (BCryptOpenAlgorithmProvider( &ret->alg_handle, alg, MS_PRIMITIVE_PROVIDER, 0 ))
+ if (BCryptOpenAlgorithmProvider( &alg_handle, alg, MS_PRIMITIVE_PROVIDER, 0 ))
{
heap_free( ret );
- return 0;
+ return NULL;
}
- if (BCryptCreateHash( ret->alg_handle, &ret->handle, NULL, 0, NULL, 0, 0 ))
+ if (BCryptCreateHash( alg_handle, &ret->handle, NULL, 0, NULL, 0, 0 ))
{
- BCryptCloseAlgorithmProvider( ret->alg_handle, 0 );
+ BCryptCloseAlgorithmProvider( alg_handle, 0 );
heap_free( ret );
- return 0;
+ return NULL;
}
+
+ BCryptCloseAlgorithmProvider( alg_handle, 0 );
return ret;
}
@@ -537,6 +539,14 @@ BOOL WINAPI CPCreateHash( HCRYPTPROV hprov, ALG_ID algid, HCRYPTKEY hkey, DWORD
return TRUE;
}
+static void destroy_hash( struct hash *hash )
+{
+ if (!hash) return;
+ BCryptDestroyHash( hash->handle );
+ hash->magic = 0;
+ heap_free( hash );
+}
+
BOOL WINAPI CPDestroyHash( HCRYPTPROV hprov, HCRYPTHASH hhash )
{
struct hash *hash = (struct hash *)hhash;
@@ -549,11 +559,7 @@ BOOL WINAPI CPDestroyHash( HCRYPTPROV hprov, HCRYPTHASH hhash )
return FALSE;
}
- BCryptDestroyHash( hash->handle );
- BCryptCloseAlgorithmProvider( hash->alg_handle, 0 );
-
- hash->magic = 0;
- heap_free( hash );
+ destroy_hash( hash );
return TRUE;
}
More information about the wine-cvs
mailing list