From 0080d3d691913577538801696a4b70edc930b4a3 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Mon, 20 Aug 2007 17:43:12 -0700 Subject: [PATCH] crypt32: Make a helper function to a free a signed message's handles. --- dlls/crypt32/msg.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 9b9b8434ed1..b67dbbd6f9c 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -805,6 +805,20 @@ typedef struct _CSignedEncodeMsg CSignedMsgData msg_data; } CSignedEncodeMsg; +static void CSignedMsgData_CloseHandles(CSignedMsgData *msg_data) +{ + DWORD i; + + for (i = 0; i < msg_data->info->cSignerInfo; i++) + { + CryptDestroyKey(msg_data->signerHandles[i].key); + CryptDestroyHash(msg_data->signerHandles[i].contentHash); + CryptDestroyHash(msg_data->signerHandles[i].authAttrHash); + CryptReleaseContext(msg_data->signerHandles[i].prov, 0); + } + CryptMemFree(msg_data->signerHandles); +} + static void CSignedEncodeMsg_Close(HCRYPTMSG hCryptMsg) { CSignedEncodeMsg *msg = (CSignedEncodeMsg *)hCryptMsg; @@ -814,14 +828,8 @@ static void CSignedEncodeMsg_Close(HCRYPTMSG hCryptMsg) CRYPT_FreeBlobArray((BlobArray *)&msg->msg_data.info->cCertEncoded); CRYPT_FreeBlobArray((BlobArray *)&msg->msg_data.info->cCrlEncoded); for (i = 0; i < msg->msg_data.info->cSignerInfo; i++) - { CSignerInfo_Free(&msg->msg_data.info->rgSignerInfo[i]); - CryptDestroyKey(msg->msg_data.signerHandles[i].key); - CryptDestroyHash(msg->msg_data.signerHandles[i].contentHash); - CryptDestroyHash(msg->msg_data.signerHandles[i].authAttrHash); - CryptReleaseContext(msg->msg_data.signerHandles[i].prov, 0); - } - CryptMemFree(msg->msg_data.signerHandles); + CSignedMsgData_CloseHandles(&msg->msg_data); CryptMemFree(msg->msg_data.info->rgSignerInfo); CryptMemFree(msg->msg_data.info); }