Click here to Skip to main content
16,012,082 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: IPHLPAPI.DLL + Windows 95 (yes the old one) Pin
Michael P Butler19-Nov-03 7:31
Michael P Butler19-Nov-03 7:31 
GeneralRe: IPHLPAPI.DLL + Windows 95 (yes the old one) Pin
Anonymous19-Nov-03 7:46
Anonymous19-Nov-03 7:46 
GeneralRe: IPHLPAPI.DLL + Windows 95 (yes the old one) Pin
Anonymous19-Nov-03 7:51
Anonymous19-Nov-03 7:51 
GeneralRe: IPHLPAPI.DLL + Windows 95 (yes the old one) Pin
David Crow19-Nov-03 8:48
David Crow19-Nov-03 8:48 
GeneralRe: IPHLPAPI.DLL + Windows 95 (yes the old one) Pin
Anonymous19-Nov-03 20:08
Anonymous19-Nov-03 20:08 
GeneralRe: IPHLPAPI.DLL + Windows 95 (yes the old one) Pin
Anonymous19-Nov-03 20:13
Anonymous19-Nov-03 20:13 
GeneralRe: IPHLPAPI.DLL + Windows 95 (yes the old one) Pin
David Crow21-Nov-03 9:11
David Crow21-Nov-03 9:11 
GeneralBug in CStringT operator= Pin
Konrad Windszus19-Nov-03 6:49
Konrad Windszus19-Nov-03 6:49 
I think I found a bug in the MFC 7.1.

There is an error during assignment of a LPWSTR to a CString in an MBCS or ANSI application.
If you have something like this

LPWSTR pWStr; // contains an WideString
CString str;
str = pWStr; // <- here is the bug


In the third line the following member of CString is called:

CStringT& operator=( PCYSTR pszSrc ) [cstringt.h, line 988]

which calls GetBaseTypeLength [cstringt.h, line 429]

This member returns the size of the pWStr (via WideCharToMultiByte) - 1. That means that the terminating NULL-character is not counted.
So the reserved memory is too small to contain the whole pWStr including terminating NULL!
In the following call of StringTraits::ConvertToBaseType( pszBuffer, nDestLength, pszSrc ) in line 995 the destLengh doesn't include the NULL character. But ConvertToBaseType implicitly calls WideCharToMultiByte with the following parameters:

::WideCharToMultiByte( _AtlGetConversionACP(), 0, pszSrc, -1, pszDest, nDestLength, NULL, NULL );

This function returns the error code 0, because the reserved memory in pszDest is one byte to small.

To my mind this is an error in the MFCs. I only checked this in MFC 7.1. Please tell me, if you can reproduce the problem perhaps in other MFC version, too.

Thanks in advance
Konrad
GeneralRe: Bug in CStringT operator= Pin
Joe Woodbury19-Nov-03 9:37
professionalJoe Woodbury19-Nov-03 9:37 
GeneralRe: Bug in CStringT operator= Pin
Brian Shifrin19-Nov-03 15:35
Brian Shifrin19-Nov-03 15:35 
QuestionHow do I change the program id for a com ? Pin
WoodyMou19-Nov-03 5:19
WoodyMou19-Nov-03 5:19 
AnswerRe: How do I change the program id for a com ? Pin
valikac19-Nov-03 5:48
valikac19-Nov-03 5:48 
AnswerRe: How do I change the program id for a com ? Pin
peterchen19-Nov-03 6:47
peterchen19-Nov-03 6:47 
QuestionHow to send data to ethernet if Mac Address is known Pin
Hemant kulkarni19-Nov-03 3:32
Hemant kulkarni19-Nov-03 3:32 
AnswerRe: How to send data to ethernet if Mac Address is known Pin
David Crow19-Nov-03 5:55
David Crow19-Nov-03 5:55 
AnswerRe: How to send data to ethernet if Mac Address is known Pin
Peak19-Nov-03 9:59
Peak19-Nov-03 9:59 
GeneralTime measure Pin
chadell19-Nov-03 3:27
chadell19-Nov-03 3:27 
GeneralRe: Time measure Pin
David Crow19-Nov-03 3:31
David Crow19-Nov-03 3:31 
GeneralRe: Time measure Pin
igor196019-Nov-03 9:56
igor196019-Nov-03 9:56 
GeneralRe: Time measure Pin
David Crow19-Nov-03 10:06
David Crow19-Nov-03 10:06 
GeneralRe: Time measure Pin
Anonymous19-Nov-03 23:08
Anonymous19-Nov-03 23:08 
GeneralRe: Time measure Pin
David Crow20-Nov-03 5:01
David Crow20-Nov-03 5:01 
GeneralRe: Time measure Pin
igor196025-Nov-03 13:38
igor196025-Nov-03 13:38 
GeneralRe: Time measure Pin
valikac19-Nov-03 5:48
valikac19-Nov-03 5:48 
GeneralRe: Time measure Pin
igor196019-Nov-03 9:57
igor196019-Nov-03 9:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.