Commit 1fb28509 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

crypt32: Consistently use CryptMemAlloc/Free().

parent dd91e541
......@@ -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;
......
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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, &params ) ||
!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() );
......
......@@ -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, &params ))
{
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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment