Commit 2e4242b5 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: If a decoding function failed, free the memory allocated for it.

parent 4c981e20
...@@ -231,6 +231,14 @@ static BOOL CRYPT_DecodeEnsureSpace(DWORD dwFlags, ...@@ -231,6 +231,14 @@ static BOOL CRYPT_DecodeEnsureSpace(DWORD dwFlags,
return ret; return ret;
} }
static void CRYPT_FreeSpace(PCRYPT_DECODE_PARA pDecodePara, LPVOID pv)
{
if (pDecodePara && pDecodePara->pfnFree)
pDecodePara->pfnFree(pv);
else
LocalFree(pv);
}
/* Helper function to check *pcbStructInfo and set it to the required size. /* Helper function to check *pcbStructInfo and set it to the required size.
* Assumes pvStructInfo is not NULL. * Assumes pvStructInfo is not NULL.
*/ */
...@@ -540,6 +548,8 @@ static BOOL CRYPT_AsnDecodeSequence(struct AsnDecodeSequenceItem items[], ...@@ -540,6 +548,8 @@ static BOOL CRYPT_AsnDecodeSequence(struct AsnDecodeSequenceItem items[],
ret = CRYPT_AsnDecodeSequenceItems(items, cItem, ret = CRYPT_AsnDecodeSequenceItems(items, cItem,
ptr, dataLen, dwFlags, pvStructInfo, nextData, ptr, dataLen, dwFlags, pvStructInfo, nextData,
&cbDecoded); &cbDecoded);
if (!ret && (dwFlags & CRYPT_DECODE_ALLOC_FLAG))
CRYPT_FreeSpace(pDecodePara, pvStructInfo);
} }
} }
} }
...@@ -727,6 +737,8 @@ static BOOL CRYPT_AsnDecodeArray(const struct AsnArrayDescriptor *arrayDesc, ...@@ -727,6 +737,8 @@ static BOOL CRYPT_AsnDecodeArray(const struct AsnArrayDescriptor *arrayDesc,
ptr += itemDecoded; ptr += itemDecoded;
} }
} }
if (!ret && (dwFlags & CRYPT_DECODE_ALLOC_FLAG))
CRYPT_FreeSpace(pDecodePara, pvStructInfo);
} }
} }
if (itemSizes != &itemSize) if (itemSizes != &itemSize)
......
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