msi: Fix building the message string in MSI_ProcessMessage.

This commit is contained in:
Hans Leidekker 2011-03-31 11:57:47 +02:00 committed by Alexandre Julliard
parent 0aaf17c0d8
commit 31291ec205
1 changed files with 34 additions and 32 deletions

View File

@ -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++)
{
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)
{
sprintfW(number,format,i);
strcatW(message,number);
}
strcatW(message,tmp);
if (msg_field > 1)
strcatW(message, szSpace);
msi_free(tmp);
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++)
{
if (count > 1)
{
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--;
}
}
p[0] = 0;
}
TRACE("%p %p %p %x %x %s\n", gUIHandlerA, gUIHandlerW, gUIHandlerRecord,