Commit a63d7c06 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard
Browse files

crypt32/tests: Use CRT allocation functions.



Signed-off-by: default avatarNikolay Sivov <nsivov@codeweavers.com>
parent 1c5bfc12
Pipeline #1869 skipped
......@@ -23,7 +23,6 @@
#include <windows.h>
#include <wincrypt.h>
#include "wine/heap.h"
#include "wine/test.h"
#define CERT_HEADER "-----BEGIN CERTIFICATE-----\r\n"
......@@ -93,7 +92,7 @@ static WCHAR *strdupAtoW(const char *str)
if (!str) return ret;
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
ret = heap_alloc(len * sizeof(WCHAR));
ret = malloc(len * sizeof(WCHAR));
if (ret)
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
return ret;
......@@ -128,7 +127,7 @@ static void encodeAndCompareBase64_A(const BYTE *toEncode, DWORD toEncodeLen,
ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError());
ok(strLen == strLen2, "Unexpected required length %lu, expected %lu.\n", strLen2, strLen);
str = heap_alloc(strLen);
str = malloc(strLen);
/* Partially filled output buffer. */
strLen2 = strLen - 1;
......@@ -157,7 +156,7 @@ static void encodeAndCompareBase64_A(const BYTE *toEncode, DWORD toEncodeLen,
if (trailer)
ok(!strncmp(trailer, ptr, strlen(trailer)), "Expected trailer %s, got %s\n", trailer, ptr);
heap_free(str);
free(str);
}
static void encode_compare_base64_W(const BYTE *toEncode, DWORD toEncodeLen, DWORD format,
......@@ -196,7 +195,7 @@ static void encode_compare_base64_W(const BYTE *toEncode, DWORD toEncodeLen, DWO
ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
ok(strLen == strLen2, "Unexpected required length.\n");
strW = heap_alloc(strLen * sizeof(WCHAR));
strW = malloc(strLen * sizeof(WCHAR));
headerW = strdupAtoW(header);
trailerW = strdupAtoW(trailer);
......@@ -231,9 +230,9 @@ static void encode_compare_base64_W(const BYTE *toEncode, DWORD toEncodeLen, DWO
ok(!memcmp(trailerW, ptr, lstrlenW(trailerW)), "Expected trailer %s, got %s.\n", wine_dbgstr_w(trailerW),
wine_dbgstr_w(ptr));
heap_free(strW);
heap_free(headerW);
heap_free(trailerW);
free(strW);
free(headerW);
free(trailerW);
}
static DWORD binary_to_hex_len(DWORD binary_len, DWORD flags)
......@@ -299,12 +298,12 @@ static void test_CryptBinaryToString(void)
ok(strLen == tests[i].toEncodeLen, "Unexpected required length %lu.\n", strLen);
strLen2 = strLen;
str = heap_alloc(strLen);
str = malloc(strLen);
ret = CryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, str, &strLen2);
ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError());
ok(strLen == strLen2, "Expected length %lu, got %lu\n", strLen, strLen2);
ok(!memcmp(str, tests[i].toEncode, tests[i].toEncodeLen), "Unexpected value\n");
heap_free(str);
free(str);
strLen = 0;
ret = CryptBinaryToStringW(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, NULL, &strLen);
......@@ -312,12 +311,12 @@ static void test_CryptBinaryToString(void)
ok(strLen == tests[i].toEncodeLen, "Unexpected required length %lu.\n", strLen);
strLen2 = strLen;
strW = heap_alloc(strLen);
strW = malloc(strLen);
ret = CryptBinaryToStringW(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, strW, &strLen2);
ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
ok(strLen == strLen2, "Expected length %lu, got %lu\n", strLen, strLen2);
ok(!memcmp(strW, tests[i].toEncode, tests[i].toEncodeLen), "Unexpected value\n");
heap_free(strW);
free(strW);
encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BASE64,
tests[i].base64, NULL, NULL);
......@@ -338,7 +337,7 @@ static void test_CryptBinaryToString(void)
encode_compare_base64_W(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BASE64X509CRLHEADER, encodedW,
X509_HEADER, X509_TRAILER);
heap_free(encodedW);
free(encodedW);
}
for (i = 0; i < ARRAY_SIZE(testsNoCR); i++)
......@@ -352,13 +351,13 @@ static void test_CryptBinaryToString(void)
ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError());
strLen2 = strLen;
str = heap_alloc(strLen);
str = malloc(strLen);
ret = CryptBinaryToStringA(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen,
CRYPT_STRING_BINARY | CRYPT_STRING_NOCR, str, &strLen2);
ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError());
ok(strLen == strLen2, "Expected length %ld, got %ld\n", strLen, strLen2);
ok(!memcmp(str, testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen), "Unexpected value\n");
heap_free(str);
free(str);
encodeAndCompareBase64_A(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCR,
testsNoCR[i].base64, NULL, NULL);
......@@ -383,7 +382,7 @@ static void test_CryptBinaryToString(void)
CRYPT_STRING_BASE64X509CRLHEADER | CRYPT_STRING_NOCR, encodedW,
X509_HEADER_NOCR, X509_TRAILER_NOCR);
heap_free(encodedW);
free(encodedW);
}
/* Systems that don't support HEXRAW format convert to BASE64 instead - 3 bytes in -> 4 chars + crlf + 1 null out. */
......@@ -420,9 +419,9 @@ static void test_CryptBinaryToString(void)
strLen2 += sizeof(input) * 2 + 1;
ok(strLen == strLen2, "Expected length %ld, got %ld\n", strLen2, strLen);
hex = heap_alloc(strLen * sizeof(WCHAR));
hex = malloc(strLen * sizeof(WCHAR));
memset(hex, 0xcc, strLen * sizeof(WCHAR));
ptr = cmp = heap_alloc(strLen * sizeof(WCHAR));
ptr = cmp = malloc(strLen * sizeof(WCHAR));
for (j = 0; j < ARRAY_SIZE(input); j++)
{
*ptr++ = hexdig[(input[j] >> 4) & 0xf];
......@@ -465,8 +464,8 @@ static void test_CryptBinaryToString(void)
ok(strLen == strLen2, "Expected length %ld, got %ld\n", strLen, strLen2);
ok(!memcmp(hex, cmp, strLen * sizeof(WCHAR)), "Unexpected value\n");
heap_free(hex);
heap_free(cmp);
free(hex);
free(cmp);
}
for (k = 0; k < ARRAY_SIZE(sizes); k++)
......@@ -483,10 +482,10 @@ static void test_CryptBinaryToString(void)
strLen2 = binary_to_hex_len(sizes[k], CRYPT_STRING_HEX | flags[i]);
ok(strLen == strLen2, "%lu: Expected length %ld, got %ld\n", i, strLen2, strLen);
hex = heap_alloc(strLen * sizeof(WCHAR) + 256);
hex = malloc(strLen * sizeof(WCHAR) + 256);
memset(hex, 0xcc, strLen * sizeof(WCHAR));
ptr = cmp = heap_alloc(strLen * sizeof(WCHAR) + 256);
ptr = cmp = malloc(strLen * sizeof(WCHAR) + 256);
for (j = 0; j < sizes[k]; j++)
{
*ptr++ = hexdig[(input[j] >> 4) & 0xf];
......@@ -552,8 +551,8 @@ static void test_CryptBinaryToString(void)
ok(strLen == strLen2, "%lu: Expected length %ld, got %ld\n", i, strLen, strLen2);
ok(!memcmp(hex, cmp, strLen * sizeof(WCHAR)), "%lu: got %s\n", i, wine_dbgstr_wn(hex, strLen));
heap_free(hex);
heap_free(cmp);
free(hex);
free(cmp);
}
}
......@@ -569,7 +568,7 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
len += strlen(header);
if (trailer)
len += strlen(trailer);
str = HeapAlloc(GetProcessHeap(), 0, len);
str = malloc(len);
if (str)
{
LPBYTE buf;
......@@ -586,7 +585,7 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
ret = CryptStringToBinaryA(str, 0, useFormat, NULL, &bufLen, NULL,
NULL);
ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError());
buf = HeapAlloc(GetProcessHeap(), 0, bufLen);
buf = malloc(bufLen);
if (buf)
{
DWORD skipped, usedFormat;
......@@ -605,7 +604,7 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
ok(skipped == 0, "Expected skipped 0, got %ld\n", skipped);
ok(usedFormat == expectedFormat, "Expected format %ld, got %ld\n",
expectedFormat, usedFormat);
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
}
/* Check again, but with garbage up front */
......@@ -625,7 +624,7 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
"Expected !ret and last error ERROR_INVALID_DATA, got ret=%d, error=%ld\n", ret, GetLastError());
if (ret)
{
buf = HeapAlloc(GetProcessHeap(), 0, bufLen);
buf = malloc(bufLen);
if (buf)
{
DWORD skipped, usedFormat;
......@@ -636,10 +635,10 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
ok(skipped == strlen(garbage),
"Expected %d characters of \"%s\" skipped when trying format %08lx, got %ld (used format is %08lx)\n",
lstrlenA(garbage), str, useFormat, skipped, usedFormat);
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
}
}
HeapFree(GetProcessHeap(), 0, str);
free(str);
}
}
......
......@@ -554,7 +554,7 @@ static void testCertProperties(void)
ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError());
if (ret)
{
LPBYTE buf = HeapAlloc(GetProcessHeap(), 0, size);
LPBYTE buf = malloc(size);
if (buf)
{
......@@ -563,7 +563,7 @@ static void testCertProperties(void)
ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
GetLastError());
ok(!memcmp(buf, subjectKeyId, size), "Unexpected subject key id\n");
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
}
}
CertFreeCertificateContext(context);
......@@ -1640,7 +1640,7 @@ static void testGetIssuerCert(void)
size = 0;
ok(CertStrToNameW(X509_ASN_ENCODING, L"CN=dummy, T=Test", CERT_X500_NAME_STR, NULL, NULL, &size, NULL),
"CertStrToName should have worked\n");
certencoded = HeapAlloc(GetProcessHeap(), 0, size);
certencoded = malloc(size);
ok(CertStrToNameW(X509_ASN_ENCODING, L"CN=dummy, T=Test", CERT_X500_NAME_STR, NULL, certencoded, &size, NULL),
"CertStrToName should have worked\n");
certsubject.pbData = certencoded;
......@@ -1663,7 +1663,7 @@ static void testGetIssuerCert(void)
CertFreeCertificateContext(cert2);
CertFreeCertificateContext(cert3);
CertCloseStore(store, 0);
HeapFree(GetProcessHeap(), 0, certencoded);
free(certencoded);
/* Test root storage self-signed certificate */
store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER, L"ROOT");
......@@ -1913,7 +1913,7 @@ static void testVerifyCertSig(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned,
}
CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE, X509_ASN_ENCODING,
(LPSTR)sigOID, 0, NULL, NULL, &pubKeySize);
pubKeyInfo = HeapAlloc(GetProcessHeap(), 0, pubKeySize);
pubKeyInfo = malloc(pubKeySize);
if (pubKeyInfo)
{
ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE,
......@@ -1927,7 +1927,7 @@ static void testVerifyCertSig(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned,
ok(ret, "CryptVerifyCertificateSignature failed: %08lx\n",
GetLastError());
}
HeapFree(GetProcessHeap(), 0, pubKeyInfo);
free(pubKeyInfo);
}
LocalFree(cert);
}
......@@ -2000,7 +2000,7 @@ static void testVerifyCertSigEx(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigne
*/
CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE, X509_ASN_ENCODING,
(LPSTR)sigOID, 0, NULL, NULL, &size);
pubKeyInfo = HeapAlloc(GetProcessHeap(), 0, size);
pubKeyInfo = malloc(size);
if (pubKeyInfo)
{
ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE,
......@@ -2014,7 +2014,7 @@ static void testVerifyCertSigEx(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigne
ok(ret, "CryptVerifyCertificateSignatureEx failed: %08lx\n",
GetLastError());
}
HeapFree(GetProcessHeap(), 0, pubKeyInfo);
free(pubKeyInfo);
}
LocalFree(cert);
}
......@@ -2114,7 +2114,7 @@ static void testSignAndEncodeCert(void)
/* oid_rsa_md5 not present in some win2k */
if (ret)
{
LPBYTE buf = HeapAlloc(GetProcessHeap(), 0, size);
LPBYTE buf = malloc(size);
if (buf)
{
......@@ -2135,7 +2135,7 @@ static void testSignAndEncodeCert(void)
else if (size == sizeof(md5SignedEmptyCertNoNull))
ok(!memcmp(buf, md5SignedEmptyCertNoNull, size),
"Unexpected value\n");
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
}
}
}
......@@ -2188,7 +2188,7 @@ static void testCreateSelfSignCert(void)
ok(ret && size, "Expected non-zero key provider info\n");
if (size)
{
PCRYPT_KEY_PROV_INFO pInfo = HeapAlloc(GetProcessHeap(), 0, size);
PCRYPT_KEY_PROV_INFO pInfo = malloc(size);
if (pInfo)
{
......@@ -2206,7 +2206,7 @@ static void testCreateSelfSignCert(void)
ok(pInfo->dwKeySpec == AT_SIGNATURE,
"Expected AT_SIGNATURE, got %ld\n", pInfo->dwKeySpec);
}
HeapFree(GetProcessHeap(), 0, pInfo);
free(pInfo);
}
}
......@@ -2262,7 +2262,7 @@ static void testCreateSelfSignCert(void)
ok(ret && size, "Expected non-zero key provider info\n");
if (size)
{
PCRYPT_KEY_PROV_INFO pInfo = HeapAlloc(GetProcessHeap(), 0, size);
PCRYPT_KEY_PROV_INFO pInfo = malloc(size);
if (pInfo)
{
......@@ -2280,7 +2280,7 @@ static void testCreateSelfSignCert(void)
ok(pInfo->dwKeySpec == AT_SIGNATURE,
"Expected AT_SIGNATURE, got %ld\n", pInfo->dwKeySpec);
}
HeapFree(GetProcessHeap(), 0, pInfo);
free(pInfo);
}
}
......@@ -2309,7 +2309,7 @@ static void testCreateSelfSignCert(void)
ok(ret && size, "Expected non-zero key provider info\n");
if (size)
{
PCRYPT_KEY_PROV_INFO pInfo = HeapAlloc(GetProcessHeap(), 0, size);
PCRYPT_KEY_PROV_INFO pInfo = malloc(size);
if (pInfo)
{
......@@ -2327,7 +2327,7 @@ static void testCreateSelfSignCert(void)
ok(pInfo->dwKeySpec == AT_KEYEXCHANGE,
"Expected AT_KEYEXCHANGE, got %ld\n", pInfo->dwKeySpec);
}
HeapFree(GetProcessHeap(), 0, pInfo);
free(pInfo);
}
}
......@@ -2386,7 +2386,7 @@ static void testCreateSelfSignCert(void)
ok(ret && size, "Expected non-zero key provider info\n");
if (size)
{
PCRYPT_KEY_PROV_INFO pInfo = HeapAlloc(GetProcessHeap(), 0, size);
PCRYPT_KEY_PROV_INFO pInfo = malloc(size);
if (pInfo)
{
......@@ -2404,7 +2404,7 @@ static void testCreateSelfSignCert(void)
ok(pInfo->dwKeySpec == AT_KEYEXCHANGE,
"Expected AT_KEYEXCHANGE, got %ld\n", pInfo->dwKeySpec);
}
HeapFree(GetProcessHeap(), 0, pInfo);
free(pInfo);
}
}
......@@ -2627,7 +2627,7 @@ static void testKeyUsage(void)
ret = CertGetEnhancedKeyUsage(context,
CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG, NULL, &bufSize);
ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
buf = HeapAlloc(GetProcessHeap(), 0, bufSize);
buf = malloc(bufSize);
if (buf)
{
PCERT_ENHKEY_USAGE pUsage = (PCERT_ENHKEY_USAGE)buf;
......@@ -2644,11 +2644,11 @@ static void testKeyUsage(void)
ok(!strcmp(pUsage->rgpszUsageIdentifier[i], keyUsages[i]),
"Expected %s, got %s\n", keyUsages[i],
pUsage->rgpszUsageIdentifier[i]);
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
}
ret = CertGetEnhancedKeyUsage(context, 0, NULL, &bufSize);
ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
buf = HeapAlloc(GetProcessHeap(), 0, bufSize);
buf = malloc(bufSize);
if (buf)
{
PCERT_ENHKEY_USAGE pUsage = (PCERT_ENHKEY_USAGE)buf;
......@@ -2668,7 +2668,7 @@ static void testKeyUsage(void)
ok(!strcmp(pUsage->rgpszUsageIdentifier[i], keyUsages[i]),
"Expected %s, got %s\n", keyUsages[i],
pUsage->rgpszUsageIdentifier[i]);
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
}
/* Shouldn't find it as an extended property */
ret = CertGetEnhancedKeyUsage(context,
......@@ -2681,7 +2681,7 @@ static void testKeyUsage(void)
GetLastError());
ret = CertGetEnhancedKeyUsage(context, 0, NULL, &bufSize);
ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
buf = HeapAlloc(GetProcessHeap(), 0, bufSize);
buf = malloc(bufSize);
if (buf)
{
PCERT_ENHKEY_USAGE pUsage = (PCERT_ENHKEY_USAGE)buf;
......@@ -2696,13 +2696,13 @@ static void testKeyUsage(void)
ok(!strcmp(pUsage->rgpszUsageIdentifier[0], szOID_RSA_RSA),
"Expected %s, got %s\n", szOID_RSA_RSA,
pUsage->rgpszUsageIdentifier[0]);
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
}
/* But querying the cert directly returns its usage */
ret = CertGetEnhancedKeyUsage(context,
CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG, NULL, &bufSize);
ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
buf = HeapAlloc(GetProcessHeap(), 0, bufSize);
buf = malloc(bufSize);
if (buf)
{
PCERT_ENHKEY_USAGE pUsage = (PCERT_ENHKEY_USAGE)buf;
......@@ -2718,7 +2718,7 @@ static void testKeyUsage(void)
ok(!strcmp(pUsage->rgpszUsageIdentifier[i], keyUsages[i]),
"Expected %s, got %s\n", keyUsages[i],
pUsage->rgpszUsageIdentifier[i]);
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
}
/* And removing the only usage identifier in the extended property
* results in the cert's key usage being found.
......@@ -2727,7 +2727,7 @@ static void testKeyUsage(void)
ok(ret, "CertRemoveEnhancedKeyUsage failed: %08lx\n", GetLastError());
ret = CertGetEnhancedKeyUsage(context, 0, NULL, &bufSize);
ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
buf = HeapAlloc(GetProcessHeap(), 0, bufSize);
buf = malloc(bufSize);
if (buf)
{
PCERT_ENHKEY_USAGE pUsage = (PCERT_ENHKEY_USAGE)buf;
......@@ -2743,7 +2743,7 @@ static void testKeyUsage(void)
ok(!strcmp(pUsage->rgpszUsageIdentifier[i], keyUsages[i]),
"Expected %s, got %s\n", keyUsages[i],
pUsage->rgpszUsageIdentifier[i]);
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
}
CertFreeCertificateContext(context);
......@@ -2810,7 +2810,7 @@ static void testGetValidUsages(void)
ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
ok(numOIDs == 3, "Expected 3, got %d\n", numOIDs);
ok(size, "Expected non-zero size\n");
oids = HeapAlloc(GetProcessHeap(), 0, size);
oids = malloc(size);
if (oids)
{
int i;
......@@ -2825,7 +2825,7 @@ static void testGetValidUsages(void)
for (i = 0; i < numOIDs; i++)
ok(!lstrcmpA(oids[i], expectedOIDs[i]), "unexpected OID %s\n",
oids[i]);
HeapFree(GetProcessHeap(), 0, oids);
free(oids);
}
numOIDs = 0xdeadbeef;
/* Oddly enough, this crashes when the number of contexts is not 1:
......@@ -2837,7 +2837,7 @@ static void testGetValidUsages(void)
ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
ok(numOIDs == 3, "Expected 3, got %d\n", numOIDs);
ok(size, "Expected non-zero size\n");
oids = HeapAlloc(GetProcessHeap(), 0, size);
oids = malloc(size);
if (oids)
{
int i;
......@@ -2847,7 +2847,7 @@ static void testGetValidUsages(void)
for (i = 0; i < numOIDs; i++)
ok(!lstrcmpA(oids[i], expectedOIDs[i]), "unexpected OID %s\n",
oids[i]);
HeapFree(GetProcessHeap(), 0, oids);
free(oids);
}
numOIDs = 0xdeadbeef;
size = 0;
......@@ -2855,7 +2855,7 @@ static void testGetValidUsages(void)
ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
ok(numOIDs == 2, "Expected 2, got %d\n", numOIDs);
ok(size, "Expected non-zero size\n");
oids = HeapAlloc(GetProcessHeap(), 0, size);
oids = malloc(size);
if (oids)
{
int i;
......@@ -2865,7 +2865,7 @@ static void testGetValidUsages(void)
for (i = 0; i < numOIDs; i++)
ok(!lstrcmpA(oids[i], expectedOIDs2[i]), "unexpected OID %s\n",
oids[i]);
HeapFree(GetProcessHeap(), 0, oids);
free(oids);
}
numOIDs = 0xdeadbeef;
size = 0;
......@@ -2873,7 +2873,7 @@ static void testGetValidUsages(void)
ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
ok(numOIDs == 2, "Expected 2, got %d\n", numOIDs);
ok(size, "Expected non-zero size\n");
oids = HeapAlloc(GetProcessHeap(), 0, size);
oids = malloc(size);
if (oids)
{
int i;
......@@ -2883,7 +2883,7 @@ static void testGetValidUsages(void)
for (i = 0; i < numOIDs; i++)
ok(!lstrcmpA(oids[i], expectedOIDs2[i]), "unexpected OID %s\n",
oids[i]);
HeapFree(GetProcessHeap(), 0, oids);
free(oids);
}
CertFreeCertificateContext(contexts[0]);
CertFreeCertificateContext(contexts[1]);
......@@ -4377,7 +4377,7 @@ static void testAcquireCertPrivateKey(void)
ok(ret, "CryptExportKey failed: %08lx\n", GetLastError());
if (ret)
{
LPBYTE buf = HeapAlloc(GetProcessHeap(), 0, size), encodedKey;
LPBYTE buf = malloc(size), encodedKey;
ret = CryptExportKey(key, 0, PUBLICKEYBLOB, 0, buf, &size);
ok(ret, "CryptExportKey failed: %08lx\n", GetLastError());
......@@ -4395,7 +4395,7 @@ static void testAcquireCertPrivateKey(void)
"Unexpected value\n");
LocalFree(encodedKey);
}
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
}
CryptDestroyKey(key);
}
......@@ -4404,7 +4404,7 @@ static void testAcquireCertPrivateKey(void)
ok(ret, "CryptExportPublicKeyInfoEx failed: %08lx\n", GetLastError());
if (ret)
{
PCERT_PUBLIC_KEY_INFO info = HeapAlloc(GetProcessHeap(), 0, size);
PCERT_PUBLIC_KEY_INFO info = malloc(size);
ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE, X509_ASN_ENCODING,
NULL, 0, NULL, info, &size);
......@@ -4416,7 +4416,7 @@ static void testAcquireCertPrivateKey(void)
ok(!memcmp(info->PublicKey.pbData, asnEncodedPublicKey,
info->PublicKey.cbData), "Unexpected value\n");
}
HeapFree(GetProcessHeap(), 0, info);
free(info);
}
CryptReleaseContext(csp, 0);
......@@ -4541,7 +4541,7 @@ static void testKeyProvInfo(void)
ret = CertGetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, NULL, &size);
ok(ret, "CertGetCertificateContextProperty error %#lx\n", GetLastError());
info = HeapAlloc(GetProcessHeap(), 0, size);
info = malloc(size);
ret = CertGetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, info, &size);
ok(ret, "CertGetCertificateContextProperty error %#lx\n", GetLastError());
ok(!lstrcmpW(info->pwszContainerName, containerW), "got %s\n", wine_dbgstr_w(info->pwszContainerName));
......@@ -4559,7 +4559,7 @@ static void testKeyProvInfo(void)
ok(info->rgProvParam[1].cbData == param[1].cbData, "got %#lx\n", info->rgProvParam[1].cbData);
ok(!memcmp(info->rgProvParam[1].pbData, param[1].pbData, param[1].cbData), "param2 mismatch\n");
ok(info->rgProvParam[1].dwFlags == param[1].dwFlags, "got %#lx\n", info->rgProvParam[1].dwFlags);
HeapFree(GetProcessHeap(), 0, info);
free(info);
ret = CertAddCertificateContextToStore(store, cert, CERT_STORE_ADD_NEW, NULL);
ok(ret, "CertAddCertificateContextToStore error %#lx\n", GetLastError());
......@@ -4578,7 +4578,7 @@ static void testKeyProvInfo(void)
ret = CertGetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, NULL, &size);
ok(ret, "CertGetCertificateContextProperty error %#lx\n", GetLastError());
info = HeapAlloc(GetProcessHeap(), 0, size);
info = malloc(size);
ret = CertGetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, info, &size);
ok(ret, "CertGetCertificateContextProperty error %#lx\n", GetLastError());
ok(!lstrcmpW(info->pwszContainerName, containerW), "got %s\n", wine_dbgstr_w(info->pwszContainerName));
......@@ -4596,7 +4596,7 @@ static void testKeyProvInfo(void)
ok(info->rgProvParam[1].cbData == param[1].cbData, "got %#lx\n", info->rgProvParam[1].cbData);
ok(!memcmp(info->rgProvParam[1].pbData, param[1].pbData, param[1].cbData), "param2 mismatch\n");
ok(info->rgProvParam[1].dwFlags == param[1].dwFlags, "got %#lx\n", info->rgProvParam[1].dwFlags);
HeapFree(GetProcessHeap(), 0, info);
free(info);
ret = CertDeleteCertificateFromStore(cert);
ok(ret, "CertDeleteCertificateFromStore error %#lx\n", GetLastError());
......@@ -4675,7 +4675,7 @@ static void test_VerifySignature(void)
ok(!status, "got %#lx\n", status);
ok(hash_len == sizeof(hash_value), "got %lu\n", hash_len);
sig_value = HeapAlloc(GetProcessHeap(), 0, info->Signature.cbData);
sig_value = malloc(info->Signature.cbData);
for (i = 0; i < info->Signature.cbData; i++)
sig_value[i] = info->Signature.pbData[info->Signature.cbData - i - 1];
......@@ -4683,7 +4683,7 @@ static void test_VerifySignature(void)
status = BCryptVerifySignature(bkey, &pad, hash_value, sizeof(hash_value), sig_value, info->Signature.cbData, BCRYPT_PAD_PKCS1);
ok(!status, "got %#lx\n", status);
HeapFree(GetProcessHeap(), 0, sig_value);
free(sig_value);
BCryptDestroyHash(bhash);
BCryptCloseAlgorithmProvider(alg, 0);
BCryptDestroyKey(bkey);
......
......@@ -2592,7 +2592,7 @@ static void test_decodeRsaPublicKey_Bcrypt(DWORD dwEncoding)
ok(!memcmp(pubexp, pubexp_expected, sizeof(pubexp_expected)), "Wrong exponent\n");
todo_wine ok(pubexp[3] == 0xff, "Got %02x\n", pubexp[3]);
leModulus = HeapAlloc(GetProcessHeap(), 0, hdr->cbModulus);
leModulus = malloc(hdr->cbModulus);