Home Dashboard Directory Help
Search

operator>> for basic_istream crashes with multibyte character set as locale by Cutaway


Status: 

Closed
 as Fixed Help for as Fixed


2
0
Sign in
to vote
Type: Bug
ID: 616702
Opened: 10/26/2010 3:07:14 AM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description


operator>> for std::basic_istream when having imbued with japanese/korean locale(or something else with multibyte character) crashes.

bug seems to be in:
_MAKLOCBYTE() -> _Maklocbyte() in xlocale
calls _Wcrtomb() with a pointer to the char _Byte,
but _Wcrtomb() can(and does) write multi-bytes to that pointer.
nr bytes written is returned by _Wcrtomb().
So stack gets corrupted...

It's called from:
num_get::_Getifld() in xlocnum
...
basic_istream::operator>>(_LONGLONG& _Val) in istream

Details
Sign in to post a comment.
Posted by Microsoft on 2/8/2011 at 7:46 PM
Hi,

Thanks for reporting this bug. We've fixed it, and the fix will be available in VC11. Here's what I observe:

C:\Temp>type meow.cpp
#include <iostream>
#include <locale>
#include <ostream>
#include <sstream>
#include <string>
using namespace std;

int main() {
    cout << "_MSC_FULL_VER: " << _MSC_FULL_VER << endl;

    locale loc("Japanese_Japan");
    wstring s(L"1\x2192"); // Right arrow symbol
    wistringstream stream(s);
    stream.imbue(loc);
    __int64 number;
    stream >> number;

    cout << number << endl;
}

[VC10 RTM]
C:\Temp>cl /EHsc /nologo /W4 /MTd meow.cpp
meow.cpp

C:\Temp>meow
_MSC_FULL_VER: 160030319
[CRASH]

[My current build of VC11]
C:\Temp>cl /EHsc /nologo /W4 /MTd meow.cpp
meow.cpp

C:\Temp>meow
_MSC_FULL_VER: 170040203
1

C:\Temp>

If you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by Microsoft on 10/26/2010 at 6:52 PM
Thanks for your feedback. We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 10/26/2010 at 3:21 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.