|
20 | 20 | #include <new>
|
21 | 21 | #include <sstream>
|
22 | 22 | #include <string>
|
| 23 | + |
| 24 | +#include <test_death.hpp> |
23 | 25 | #if _HAS_CXX17
|
24 | 26 | #include <string_view>
|
25 | 27 | #endif // _HAS_CXX17
|
@@ -1917,17 +1919,32 @@ void test_gh_3955() {
|
1917 | 1919 | assert(s == t);
|
1918 | 1920 | }
|
1919 | 1921 |
|
1920 |
| -int main() { |
1921 |
| - run_allocator_matrix<char>(); |
| 1922 | +void test_gh_5251() { |
| 1923 | + // GH-5251 <string>: ASan annotations do not prevent writing to allocated |
| 1924 | + // but uninitialized basic_string memory |
| 1925 | + string myString; |
| 1926 | + myString.reserve(100); |
| 1927 | + char* myData = &myString[0]; |
| 1928 | + myData[50] = 'A'; // ASan should fire! |
| 1929 | +} |
| 1930 | + |
| 1931 | +int main(int argc, char* argv[]) { |
| 1932 | + std_testing::death_test_executive exec([] { |
| 1933 | + run_allocator_matrix<char>(); |
1922 | 1934 | #ifdef __cpp_char8_t
|
1923 |
| - run_allocator_matrix<char8_t>(); |
| 1935 | + run_allocator_matrix<char8_t>(); |
1924 | 1936 | #endif // __cpp_char8_t
|
1925 |
| - run_allocator_matrix<char16_t>(); |
1926 |
| - run_allocator_matrix<char32_t>(); |
1927 |
| - run_allocator_matrix<wchar_t>(); |
1928 |
| - |
1929 |
| - test_DevCom_10116361(); |
1930 |
| - test_DevCom_10109507(); |
1931 |
| - test_gh_3883(); |
1932 |
| - test_gh_3955(); |
| 1937 | + run_allocator_matrix<char16_t>(); |
| 1938 | + run_allocator_matrix<char32_t>(); |
| 1939 | + run_allocator_matrix<wchar_t>(); |
| 1940 | + |
| 1941 | + test_DevCom_10116361(); |
| 1942 | + test_DevCom_10109507(); |
| 1943 | + test_gh_3883(); |
| 1944 | + test_gh_3955(); |
| 1945 | + }); |
| 1946 | +#ifdef __SANITIZE_ADDRESS__ |
| 1947 | + exec.add_death_tests({test_gh_5251}); |
| 1948 | +#endif // ASan instrumentation enabled |
| 1949 | + return exec.run(argc, argv); |
1933 | 1950 | }
|
0 commit comments