From 2e4242b5453e661e186697a166cee259805f5ddc Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Thu, 8 Nov 2007 08:55:36 -0800 Subject: [PATCH] crypt32: If a decoding function failed, free the memory allocated for it. --- dlls/crypt32/decode.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c index 8ceceacb8b..3697c8ac86 100644 --- a/dlls/crypt32/decode.c +++ b/dlls/crypt32/decode.c @@ -231,6 +231,14 @@ static BOOL CRYPT_DecodeEnsureSpace(DWORD dwFlags, 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. * Assumes pvStructInfo is not NULL. */ @@ -540,6 +548,8 @@ static BOOL CRYPT_AsnDecodeSequence(struct AsnDecodeSequenceItem items[], ret = CRYPT_AsnDecodeSequenceItems(items, cItem, ptr, dataLen, dwFlags, pvStructInfo, nextData, &cbDecoded); + if (!ret && (dwFlags & CRYPT_DECODE_ALLOC_FLAG)) + CRYPT_FreeSpace(pDecodePara, pvStructInfo); } } } @@ -727,6 +737,8 @@ static BOOL CRYPT_AsnDecodeArray(const struct AsnArrayDescriptor *arrayDesc, ptr += itemDecoded; } } + if (!ret && (dwFlags & CRYPT_DECODE_ALLOC_FLAG)) + CRYPT_FreeSpace(pDecodePara, pvStructInfo); } } if (itemSizes != &itemSize) -- 2.32.0.93.g670b81a890