"Doug Harrison [MVP]" <ds*@mvps.org> wrote in message
news:v5********************************@4ax.com...
On Thu, 13 Oct 2005 11:49:30 +0200, "Egbert Nierop \(MVP for IIS\)"
<eg***********@nospam.invalid> wrote:
Am I the only one?
After having installed the patches as a brave MS citycen :),
this function suddenly returns one less then before or possible
vswprintf assumes the given length including the terminating zero.
Can you demonstrate this in a little console program?
ps: I established this bug. It is not windows but VC 8 which behaves
different with VC 7.
I have mailed this to Michael M (Microsoft).
BSTR __cdecl Format(PCWSTR pszFormat, ...) throw()
{
va_list args;
HRESULT hr = S_OK;
BSTR retVal = NULL;
va_start( args, pszFormat );
int len = _vscwprintf( pszFormat, args );
retVal = SysAllocStringLen(NULL, len);
if(retval != NULL)
vswprintf( retVal, (SIZE_T)len, pszFormat, args );
va_end(args);
return retVal;
}
INT main()
{
CoInitialize(NULL);
{
BSTR test = Format(L"%s, %d,%s", L"one", 2, L"three");
wprintf(test); //"output one, 2, thre" <-- BUG this used to have the
correct length in VC 7?
SysFreeString(test);
}
CoUninitialize();
return 0;
}