wine-staging/patches/bcrypt-Improvements/0025-bcrypt-Avoid-crash-in-tests-when-compiling-without-g.patch
2018-03-01 16:25:25 +11:00

54 lines
1.6 KiB
Diff

From aad04c30ad73ffec87b46b59f65fc6d451138d0c Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Mon, 26 Dec 2016 16:20:57 +0100
Subject: [PATCH 25/36] bcrypt: Avoid crash in tests when compiling without
gnutls support.
---
dlls/bcrypt/bcrypt_main.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index a9dfb00ab4..79e62e33c9 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -1310,12 +1310,19 @@ NTSTATUS WINAPI BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE algorithm, BCRYPT_
if (!alg || alg->hdr.magic != MAGIC_ALG) return STATUS_INVALID_HANDLE;
if (object) FIXME( "ignoring object buffer\n" );
+
if (!(key = heap_alloc( sizeof(*key) ))) return STATUS_NO_MEMORY;
+ {
+ *handle = NULL;
+ return STATUS_NO_MEMORY;
+ }
+
key->hdr.magic = MAGIC_KEY;
if ((status = key_init( key, alg, secret, secret_len )))
{
heap_free( key );
+ *handle = NULL;
return status;
}
@@ -1398,11 +1405,15 @@ NTSTATUS WINAPI BCryptDuplicateKey( BCRYPT_KEY_HANDLE handle, BCRYPT_KEY_HANDLE
if (!key_orig || key_orig->hdr.magic != MAGIC_KEY) return STATUS_INVALID_HANDLE;
if (!handle_copy) return STATUS_INVALID_PARAMETER;
if (!(key_copy = HeapAlloc( GetProcessHeap(), 0, sizeof(*key_copy) )))
+ {
+ *handle_copy = NULL;
return STATUS_NO_MEMORY;
+ }
if ((status = key_duplicate( key_orig, key_copy )))
{
HeapFree( GetProcessHeap(), 0, key_copy );
+ *handle_copy = NULL;
return status;
}
--
2.16.1