Skip to content

Commit 34b6045

Browse files
committed
Add exception guard for constructor vector(n, x, a)
1 parent e914421 commit 34b6045

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

libcxx/include/vector

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,12 @@ public:
487487
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
488488
vector(size_type __n, const value_type& __x, const allocator_type& __a)
489489
: __alloc_(__a) {
490+
auto __guard = std::__make_exception_guard(__destroy_vector(*this));
490491
if (__n > 0) {
491492
__vallocate(__n);
492493
__construct_at_end(__n, __x);
493494
}
495+
__guard.__complete();
494496
}
495497

496498
template <class _InputIterator,

0 commit comments

Comments
 (0)