Skip to content

Commit

Permalink
Fix WcaErrorMessage cArgs==-1 case.
Browse files Browse the repository at this point in the history
Count args before creating message record.

Fixes wixtoolset/issues#7422.
Fixes wixtoolset/issues#7444.
  • Loading branch information
barnson committed Apr 25, 2023
1 parent eadea8a commit 5460ccc
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/libs/wcautil/WixToolset.WcaUtil/wcawrap.cpp
Expand Up @@ -41,6 +41,19 @@ extern "C" UINT __cdecl WcaErrorMessage(
MSIHANDLE hRec = NULL;
va_list args = NULL;

va_start(args, cArgs);
if (-1 == cArgs)
{
LPCWSTR wzArg = NULL;
va_list iter = args;
cArgs = 0;

while (NULL != (wzArg = va_arg(iter, WCHAR*)) && L'\0' != *wzArg)
{
++cArgs;
}
}

uiType |= INSTALLMESSAGE_ERROR; // ensure error type is set
hRec = ::MsiCreateRecord(cArgs + 2);
if (!hRec)
Expand All @@ -55,19 +68,6 @@ extern "C" UINT __cdecl WcaErrorMessage(
er = ::MsiRecordSetInteger(hRec, 2, hrError);
ExitOnFailure(HRESULT_FROM_WIN32(er), "failed to set hresult code into error message");

va_start(args, cArgs);
if (-1 == cArgs)
{
LPCWSTR wzArg = NULL;
va_list iter = args;
cArgs = 0;

while (NULL != (wzArg = va_arg(iter, WCHAR*)) && L'\0' != *wzArg)
{
++cArgs;
}
}

for (INT i = 0; i < cArgs; i++)
{
er = ::MsiRecordSetStringW(hRec, i + 3, va_arg(args, WCHAR*));
Expand Down

0 comments on commit 5460ccc

Please sign in to comment.