Commit 31291ec2 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi: Fix building the message string in MSI_ProcessMessage.

parent 0aaf17c0
......@@ -1703,8 +1703,7 @@ MSIHANDLE WINAPI MsiGetActiveDatabase(MSIHANDLE hInstall)
return handle;
}
INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType,
MSIRECORD *record)
INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType, MSIRECORD *record )
{
static const WCHAR szActionData[] =
{'A','c','t','i','o','n','D','a','t','a',0};
......@@ -1713,10 +1712,9 @@ INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType,
static const WCHAR szActionText[] =
{'A','c','t','i','o','n','T','e','x','t',0};
LPWSTR message;
DWORD sz, total_size = 0, log_type = 0;
INT i, rc = 0;
DWORD i, len, total_len, log_type = 0;
INT rc = 0;
char *msg;
int len;
TRACE("%x\n", eMessageType);
......@@ -1769,35 +1767,39 @@ INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType,
}
else
{
INT msg_field=1;
message = msi_alloc(1*sizeof (WCHAR));
message[0]=0;
msg_field = MSI_RecordGetFieldCount(record);
for (i = 1; i <= msg_field; i++)
static const WCHAR format[] = {'%','u',':',' ',0};
UINT count = MSI_RecordGetFieldCount( record );
WCHAR *p;
total_len = 1;
for (i = 1; i <= count; i++)
{
len = 0;
MSI_RecordGetStringW( record, i, NULL, &len );
total_len += len + 13;
}
p = message = msi_alloc( total_len * sizeof(WCHAR) );
if (!p) return ERROR_OUTOFMEMORY;
for (i = 1; i <= count; i++)
{
LPWSTR tmp;
WCHAR number[3];
static const WCHAR format[] = { '%','i',':',' ',0};
sz = 0;
MSI_RecordGetStringW(record,i,NULL,&sz);
sz+=4;
total_size+=sz*sizeof(WCHAR);
tmp = msi_alloc(sz*sizeof(WCHAR));
message = msi_realloc(message,total_size*sizeof (WCHAR));
MSI_RecordGetStringW(record,i,tmp,&sz);
if (msg_field > 1)
if (count > 1)
{
sprintfW(number,format,i);
strcatW(message,number);
len = sprintfW( p, format, i );
total_len -= len;
p += len;
}
len = total_len;
MSI_RecordGetStringW( record, i, p, &len );
total_len -= len;
p += len;
if (count > 1 && total_len)
{
*p++ = ' ';
total_len--;
}
strcatW(message,tmp);
if (msg_field > 1)
strcatW(message, szSpace);
msi_free(tmp);
}
p[0] = 0;
}
TRACE("%p %p %p %x %x %s\n", gUIHandlerA, gUIHandlerW, gUIHandlerRecord,
......
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