Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/crypt32/cert.c | 12 ++++++------
dlls/crypt32/chain.c | 4 ++--
dlls/crypt32/msg.c | 4 ++--
dlls/crypt32/pfx.c | 12 +++++-------
dlls/crypt32/rootstore.c | 9 ++++-----
dlls/crypt32/serialize.c | 4 ++--
6 files changed, 21 insertions(+), 24 deletions(-)
diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c
index b7789fd6fcd..ad39b7d18c7 100644
--- a/dlls/crypt32/cert.c
+++ b/dlls/crypt32/cert.c
@@ -677,7 +677,7 @@ static BOOL CertContext_SetKeyProvInfoProperty(CONTEXT_PROPERTY_LIST *properties
for (i = 0; i < info->cProvParam; i++)
size += sizeof(CRYPT_KEY_PROV_PARAM) + info->rgProvParam[i].cbData;
- prop = HeapAlloc(GetProcessHeap(), 0, size);
+ prop = CryptMemAlloc(size);
if (!prop)
{
SetLastError(ERROR_OUTOFMEMORY);
@@ -687,7 +687,7 @@ static BOOL CertContext_SetKeyProvInfoProperty(CONTEXT_PROPERTY_LIST *properties
copy_KeyProvInfoProperty(info, prop);
ret = ContextPropertyList_SetProperty(properties, CERT_KEY_PROV_INFO_PROP_ID, (const BYTE *)prop, size);
- HeapFree(GetProcessHeap(), 0, prop);
+ CryptMemFree(prop);
return ret;
}
@@ -865,7 +865,7 @@ static BOOL CRYPT_AcquirePrivateKeyFromProvInfo(PCCERT_CONTEXT pCert, DWORD dwFl
CERT_KEY_PROV_INFO_PROP_ID, 0, &size);
if (ret)
{
- info = HeapAlloc(GetProcessHeap(), 0, size);
+ info = CryptMemAlloc(size);
if (info)
{
ret = CertGetCertificateContextProperty(pCert,
@@ -901,7 +901,7 @@ static BOOL CRYPT_AcquirePrivateKeyFromProvInfo(PCCERT_CONTEXT pCert, DWORD dwFl
SetLastError(CRYPT_E_NO_KEY_PROPERTY);
}
if (allocated)
- HeapFree(GetProcessHeap(), 0, info);
+ CryptMemFree(info);
return ret;
}
@@ -953,7 +953,7 @@ BOOL WINAPI CryptAcquireCertificatePrivateKey(PCCERT_CONTEXT pCert,
if (ret)
{
- info = HeapAlloc(GetProcessHeap(), 0, size);
+ info = CryptMemAlloc(size);
ret = CertGetCertificateContextProperty(pCert,
CERT_KEY_PROV_INFO_PROP_ID, info, &size);
if (ret)
@@ -1003,7 +1003,7 @@ BOOL WINAPI CryptAcquireCertificatePrivateKey(PCCERT_CONTEXT pCert,
}
}
}
- HeapFree(GetProcessHeap(), 0, info);
+ CryptMemFree(info);
if (cert_in_store)
CertFreeCertificateContext(cert_in_store);
return ret;
diff --git a/dlls/crypt32/chain.c b/dlls/crypt32/chain.c
index 3e9bdb66e0a..cf244f2ac6c 100644
--- a/dlls/crypt32/chain.c
+++ b/dlls/crypt32/chain.c
@@ -2007,7 +2007,7 @@ static PCCERT_CONTEXT CRYPT_FindIssuer(const CertificateChainEngine *engine, con
if(!res)
return NULL;
- urls = HeapAlloc(GetProcessHeap(), 0, size);
+ urls = CryptMemAlloc(size);
if(!urls)
return NULL;
@@ -2045,7 +2045,7 @@ static PCCERT_CONTEXT CRYPT_FindIssuer(const CertificateChainEngine *engine, con
}
}
- HeapFree(GetProcessHeap(), 0, urls);
+ CryptMemFree(urls);
return issuer;
}
diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index 6087f423f8c..63884d0c275 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -1666,12 +1666,12 @@ static BOOL CRYPT_ExportEncryptedKey(CMSG_CONTENT_ENCRYPT_INFO *info, DWORD i,
static LPVOID WINAPI mem_alloc(size_t size)
{
- return HeapAlloc(GetProcessHeap(), 0, size);
+ return CryptMemAlloc(size);
}
static VOID WINAPI mem_free(LPVOID pv)
{
- HeapFree(GetProcessHeap(), 0, pv);
+ CryptMemFree(pv);
}
diff --git a/dlls/crypt32/pfx.c b/dlls/crypt32/pfx.c
index fbcc7c72c89..54eb7f25e1b 100644
--- a/dlls/crypt32/pfx.c
+++ b/dlls/crypt32/pfx.c
@@ -17,7 +17,6 @@
*/
#include <stdarg.h>
-#include <stdlib.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
@@ -28,7 +27,6 @@
#include "crypt32_private.h"
#include "wine/debug.h"
-#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(crypt);
@@ -55,17 +53,17 @@ static HCRYPTPROV import_key( cert_store_data_t data, DWORD flags )
}
}
- params.buf = key = malloc( size );
+ params.buf = key = CryptMemAlloc( size );
if (CRYPT32_CALL( import_store_key, ¶ms ) ||
!CryptImportKey( prov, key, size, 0, flags & CRYPT_EXPORTABLE, &cryptkey ))
{
WARN( "CryptImportKey failed %08lx\n", GetLastError() );
CryptReleaseContext( prov, 0 );
- free( key );
+ CryptMemFree( key );
return 0;
}
CryptDestroyKey( cryptkey );
- free( key );
+ CryptMemFree( key );
return prov;
}
@@ -177,10 +175,10 @@ HCERTSTORE WINAPI PFXImportCertStore( CRYPT_DATA_BLOB *pfx, const WCHAR *passwor
struct import_store_cert_params import_params = { data, i, NULL, &size };
if (CRYPT32_CALL( import_store_cert, &import_params ) != STATUS_BUFFER_TOO_SMALL) break;
- import_params.buf = cert = malloc( size );
+ import_params.buf = cert = CryptMemAlloc( size );
if (!CRYPT32_CALL( import_store_cert, &import_params ))
ctx = CertCreateContext( CERT_STORE_CERTIFICATE_CONTEXT, X509_ASN_ENCODING, cert, size, 0, NULL );
- free( cert );
+ CryptMemFree( cert );
if (!ctx)
{
WARN( "CertCreateContext failed %08lx\n", GetLastError() );
diff --git a/dlls/crypt32/rootstore.c b/dlls/crypt32/rootstore.c
index 43256c71039..ab3a396b651 100644
--- a/dlls/crypt32/rootstore.c
+++ b/dlls/crypt32/rootstore.c
@@ -18,7 +18,6 @@
#include <stdarg.h>
#include <stdio.h>
-#include <stdlib.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
@@ -622,19 +621,19 @@ static void read_trusted_roots_from_known_locations(HCERTSTORE store)
if (from)
{
- params.buffer = malloc( params.size );
+ params.buffer = CryptMemAlloc( params.size );
while (!CRYPT32_CALL( enum_root_certs, ¶ms ))
{
if (needed > params.size)
{
- free( params.buffer );
- params.buffer = malloc( needed );
+ CryptMemFree( params.buffer );
+ params.buffer = CryptMemAlloc( needed );
params.size = needed;
}
else CertAddEncodedCertificateToStore( from, X509_ASN_ENCODING, params.buffer, needed,
CERT_STORE_ADD_NEW, NULL );
}
- free( params.buffer );
+ CryptMemFree( params.buffer );
check_and_store_certs(from, store);
}
CertCloseStore(from, 0);
diff --git a/dlls/crypt32/serialize.c b/dlls/crypt32/serialize.c
index e1e2593169d..47ab834bf48 100644
--- a/dlls/crypt32/serialize.c
+++ b/dlls/crypt32/serialize.c
@@ -72,7 +72,7 @@ static DWORD serialize_KeyProvInfoProperty(const CRYPT_KEY_PROV_INFO *info, stru
if (!ret) return size;
- store = HeapAlloc(GetProcessHeap(), 0, size);
+ store = CryptMemAlloc(size);
if (!store) return 0;
param = (struct store_CRYPT_KEY_PROV_PARAM *)(store + 1);
@@ -331,7 +331,7 @@ static DWORD read_serialized_KeyProvInfoProperty(const struct store_CRYPT_KEY_PR
for (i = 0; i < store->cProvParam; i++)
size += sizeof(CRYPT_KEY_PROV_PARAM) + param[i].cbData;
- info = HeapAlloc(GetProcessHeap(), 0, size);
+ info = CryptMemAlloc(size);
if (!info)
{
SetLastError(ERROR_OUTOFMEMORY);
--
2.30.2