Commit b377f834 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Don't assume a function succeeded (clang).

parent bcd14a18
......@@ -1559,38 +1559,42 @@ static BOOL WINAPI CRYPT_ExportKeyTrans(
X509_ASN_ENCODING, &keyInfo, &expKey);
if (ret)
{
BYTE *keyBlob;
DWORD size;
ret = CryptExportKey(pContentEncryptInfo->hContentEncryptKey, expKey,
SIMPLEBLOB, 0, NULL, &size);
keyBlob = CryptMemAlloc(size);
if (keyBlob)
if (ret)
{
ret = CryptExportKey(pContentEncryptInfo->hContentEncryptKey,
expKey, SIMPLEBLOB, 0, keyBlob, &size);
if (ret)
{
DWORD head = sizeof(BLOBHEADER) + sizeof(ALG_ID);
BYTE *keyBlob;
pKeyTransEncryptInfo->EncryptedKey.pbData =
CryptMemAlloc(size - head);
if (pKeyTransEncryptInfo->EncryptedKey.pbData)
keyBlob = CryptMemAlloc(size);
if (keyBlob)
{
ret = CryptExportKey(pContentEncryptInfo->hContentEncryptKey,
expKey, SIMPLEBLOB, 0, keyBlob, &size);
if (ret)
{
DWORD i, k = 0;
DWORD head = sizeof(BLOBHEADER) + sizeof(ALG_ID);
pKeyTransEncryptInfo->EncryptedKey.pbData =
CryptMemAlloc(size - head);
if (pKeyTransEncryptInfo->EncryptedKey.pbData)
{
DWORD i, k = 0;
pKeyTransEncryptInfo->EncryptedKey.cbData = size - head;
for (i = size - 1; i >= head; --i, ++k)
pKeyTransEncryptInfo->EncryptedKey.pbData[k] =
keyBlob[i];
pKeyTransEncryptInfo->EncryptedKey.cbData = size - head;
for (i = size - 1; i >= head; --i, ++k)
pKeyTransEncryptInfo->EncryptedKey.pbData[k] =
keyBlob[i];
}
else
ret = FALSE;
}
else
ret = FALSE;
CryptMemFree(keyBlob);
}
CryptMemFree(keyBlob);
else
ret = FALSE;
}
else
ret = FALSE;
CryptDestroyKey(expKey);
}
......
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