From 7ff58b52a916bf4c64be0be2e84dff11668d3de4 Mon Sep 17 00:00:00 2001 From: Mateusz Zych Date: Fri, 16 Feb 2024 23:35:10 +0300 Subject: [PATCH] [libc++][vector] Make constructor vector(count, value, allocator) exception-safe --- libcxx/include/vector | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libcxx/include/vector b/libcxx/include/vector index ce7df7a9f0420..c3e3f05671f8f 100644 --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -433,10 +433,12 @@ public: _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x, const allocator_type& __a) : __end_cap_(nullptr, __a) { + auto __guard = std::__make_exception_guard(__destroy_vector(*this)); if (__n > 0) { __vallocate(__n); __construct_at_end(__n, __x); } + __guard.__complete(); } template