From be6a7cd60499a83baff70922b253c477401b76b9 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Mon, 26 Dec 2016 16:20:57 +0100 Subject: [PATCH] bcrypt: Avoid crash in tests when compiling without gnutls support. --- dlls/bcrypt/bcrypt_main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c index 0dc0645..036a92d 100644 --- a/dlls/bcrypt/bcrypt_main.c +++ b/dlls/bcrypt/bcrypt_main.c @@ -1268,12 +1268,17 @@ 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 = HeapAlloc( GetProcessHeap(), 0, sizeof(*key) ))) return STATUS_NO_MEMORY; + if (!(key = HeapAlloc( GetProcessHeap(), 0, sizeof(*key) ))) + { + *handle = NULL; + return STATUS_NO_MEMORY; + } key->hdr.magic = MAGIC_KEY; if ((status = key_init( key, alg, secret, secret_len ))) { HeapFree( GetProcessHeap(), 0, key ); + *handle = NULL; return status; } @@ -1293,11 +1298,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; } -- 1.9.1