Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions stl/inc/xiosbase
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ public:

static void __CLRCALL_PURE_OR_CDECL _Addstd(ios_base*); // add standard stream

size_t _Stdstr; // if > 0 index of standard stream to suppress destruction
size_t _Stdstr{0}; // if > 0 index of standard stream to suppress destruction

protected:
__CLR_OR_THIS_CALL ios_base() {}
Expand Down Expand Up @@ -547,9 +547,9 @@ private:
fmtflags _Fmtfl; // format flags
streamsize _Prec; // field precision
streamsize _Wide; // field width
_Iosarray* _Arr; // pointer to first node of long/pointer array
_Fnarray* _Calls; // pointer to first node of call list
locale* _Ploc; // pointer to locale
_Iosarray* _Arr{nullptr}; // pointer to first node of long/pointer array
_Fnarray* _Calls{nullptr}; // pointer to first node of call list
locale* _Ploc{nullptr}; // pointer to locale

__PURE_APPDOMAIN_GLOBAL static int _Index;
__PURE_APPDOMAIN_GLOBAL static bool _Sync;
Expand Down
1 change: 1 addition & 0 deletions stl/src/ios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ void __CLRCALL_PURE_OR_CDECL ios_base::_Ios_base_dtor(ios_base* _This) { // dest
}

_This->_Tidy();

delete _This->_Ploc;
}

Expand Down
1 change: 1 addition & 0 deletions tests/std/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ tests\GH_001017_discrete_distribution_out_of_range
tests\GH_001059_hyperbolic_truncation
tests\GH_001086_partial_sort_copy
tests\GH_001103_countl_zero_correctness
tests\GH_001105_custom_streambuf_throws
tests\GH_001123_random_cast_out_of_range
tests\LWG2597_complex_branch_cut
tests\LWG3018_shared_ptr_function
Expand Down
4 changes: 4 additions & 0 deletions tests/std/tests/GH_001105_custom_streambuf_throws/env.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

RUNALL_INCLUDE ..\usual_matrix.lst
30 changes: 30 additions & 0 deletions tests/std/tests/GH_001105_custom_streambuf_throws/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <cassert>
#include <istream>
#include <stdexcept>

struct bad_buf : std::streambuf {
bad_buf() {
throw std::runtime_error("throw in constructor!");
}
};

struct custom_stream : std::istream {
custom_stream() : std::istream(new bad_buf{}) {}
};

int main() {

{
// GH-1105 std::istream destructor should not crash if custom streambuf implementation throws.
try {
custom_stream f{};
} catch (const std::runtime_error&) {
assert(true);
}
}

return 0;
}