473,480 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

12 octobers patches _vscwprintf( pszFormat, args ); difference!

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.

Nov 17 '05 #1
4 1486
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?

--
Doug Harrison
Visual C++ MVP
Nov 17 '05 #2

"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;

}

Nov 17 '05 #3
Hi Egbert!
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;
}
If it had worked in VC7(.1) then it was a bug in VC7(.1) and is now
corrected in VC8 :-)

The following line is wrong: int len = _vscwprintf(pszFormat, args);


You should change it to
int len = _vscwprintf(pszFormat, args) + 1;

The reason is:
_vscprintf doesn't count the terminating '\0'!
but vswprintf requires the terminating NUL in in the count.

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #4

"Jochen Kalmbach [MVP]" <no********************@holzma.de> wrote in message
news:ue*************@TK2MSFTNGP15.phx.gbl...
Hi Egbert!
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;
}


If it had worked in VC7(.1) then it was a bug in VC7(.1) and is now
corrected in VC8 :-)


Great! :<

Counting on bugs helps one to improve his skills :)
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1435
by: Brett C. | last post by:
Anthony Baxter, our ever-diligent release manager, mentioned this past week that Python 2.3.5 will most likely come to fruition some time in January (this is not guaranteed date). This means that...
18
6928
by: John M. Gabriele | last post by:
I've done some C++ and Java in the past, and have recently learned a fair amount of Python. One thing I still really don't get though is the difference between class methods and instance methods. I...
9
8124
by: Josh Mayfield | last post by:
Note: There is considerable background detail here, but I do have three questions, which are clearly marked and appear right before the sample code. I have a legitimate need to launch an EXE...
20
2374
by: Ivar | last post by:
Hi, For my supprise I found that functions have 32 parameter limit. Where to find more info about this limitation or similar limitations ? I need at least 50, 100 would be ok. Real life...
12
1602
by: Ümit | last post by:
Microsoft Never sends security patches via e-mail. This exe file may be a virus or a trojan. "Eija Silvennoinen" <kpidxbg_erbm@ogqj.com> wrote in message...
38
2279
by: Zytan | last post by:
What is the difference between these two lines? Dim args As Object() = New Object() {strText} Dim args As Object() = {strText} args seems usuable from either, say, like so: ...
7
10404
by: 7stud | last post by:
Hi, I can't find any documentation for the * operator when applied in front of a name. Is it a pointer? What about the @ operator? Are there python names for these operators that would...
11
12085
by: cmb3587 | last post by:
I have two arrays and I'm trying to create a 3rd array that is the difference between the two arrays Ex: arrayA: 3 5 8 9 arrayB: 3 4 6 9 difference of A-B: 5 8 however, my...
0
6911
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7050
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7091
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6743
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6966
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4787
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2999
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.