Juan Lang : crypt32: Use a helper function to allocate signer handles.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Aug 21 15:22:25 CDT 2007
Module: wine
Branch: master
Commit: 07ba16c291e3933037f75bb2ca5cdbab7639ff16
URL: http://source.winehq.org/git/wine.git/?a=commit;h=07ba16c291e3933037f75bb2ca5cdbab7639ff16
Author: Juan Lang <juan.lang at gmail.com>
Date: Mon Aug 20 17:48:38 2007 -0700
crypt32: Use a helper function to allocate signer handles.
---
dlls/crypt32/msg.c | 37 +++++++++++++++++++++++++------------
1 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index a50fc3f..6a9acb4 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -807,6 +807,28 @@ static BOOL CSignerHandles_Construct(CSignerHandles *handles,
return ret;
}
+/* Allocates a CSignedMsgData's handles. Assumes its info has already been
+ * constructed.
+ */
+static BOOL CSignedMsgData_AllocateHandles(CSignedMsgData *msg_data)
+{
+ BOOL ret = TRUE;
+
+ if (msg_data->info->cSignerInfo)
+ {
+ msg_data->signerHandles =
+ CryptMemAlloc(msg_data->info->cSignerInfo * sizeof(CSignerHandles));
+ if (msg_data->signerHandles)
+ memset(msg_data->signerHandles, 0,
+ msg_data->info->cSignerInfo * sizeof(CSignerHandles));
+ else
+ ret = FALSE;
+ }
+ else
+ msg_data->signerHandles = NULL;
+ return ret;
+}
+
static void CSignedMsgData_CloseHandles(CSignedMsgData *msg_data)
{
DWORD i;
@@ -1185,23 +1207,14 @@ static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags,
ret = FALSE;
if (ret && info->cSigners)
{
- msg->msg_data.signerHandles =
- CryptMemAlloc(info->cSigners * sizeof(CSignerHandles));
- if (msg->msg_data.signerHandles)
- msg->msg_data.info->rgSignerInfo =
- CryptMemAlloc(info->cSigners * sizeof(CMSG_SIGNER_INFO));
- else
- {
- ret = FALSE;
- msg->msg_data.info->rgSignerInfo = NULL;
- }
+ msg->msg_data.info->rgSignerInfo =
+ CryptMemAlloc(info->cSigners * sizeof(CMSG_SIGNER_INFO));
if (msg->msg_data.info->rgSignerInfo)
{
msg->msg_data.info->cSignerInfo = info->cSigners;
- memset(msg->msg_data.signerHandles, 0,
- msg->msg_data.info->cSignerInfo * sizeof(CSignerHandles));
memset(msg->msg_data.info->rgSignerInfo, 0,
msg->msg_data.info->cSignerInfo * sizeof(CMSG_SIGNER_INFO));
+ ret = CSignedMsgData_AllocateHandles(&msg->msg_data);
for (i = 0; ret && i < msg->msg_data.info->cSignerInfo; i++)
{
ret = CSignerInfo_Construct(
More information about the wine-cvs
mailing list