-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When a specific mix of characters in 0-255 range and not in 0-255 range is passed to wstring::find_first_of
, it crashes.
Command-line test case
**********************************************************************
** Visual Studio 2026 Developer Command Prompt v18.0.0-insiders
** Copyright (c) 2025 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
C:\Program Files\Microsoft Visual Studio\18\Insiders>cd %temp%
C:\Users\ALEXG~1\AppData\Local\Temp>type woof.cpp
#include <string>
#include <iostream>
using namespace std;
int main() {
wstring hay(200, L'z');
wstring needle;
needle.resize(32);
for (int k = 0; k != 32; k += 16) {
for (int i = 0; i != 8; ++i) {
needle[i + k] = 'a' + i;
}
for (int i = 8; i != 16; ++i) {
needle[i + k] = 0xFF00 + i;
}
}
auto pos = hay.find_first_of(needle);
cout << "Found at:" << pos;
}
C:\Users\ALEXG~1\AppData\Local\Temp>cl woof.cpp /EHsc
Microsoft (R) C/C++ Optimizing Compiler Version 19.50.35503 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
woof.cpp
Microsoft (R) Incremental Linker Version 14.50.35503.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:woof.exe
woof.obj
C:\Users\ALEXG~1\AppData\Local\Temp>woof.exe
C:\Users\ALEXG~1\AppData\Local\Temp>echo %errorlevel%
-1073741819
Expected behavior
No crash, print something, %errorlevel% zero
STL version
19.50.35503 for x64
Additional context
Reported internally
StephanTLavavej and frederick-vs-ja
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working