mirror of
https://github.com/darlinghq/darling-libcxx.git
synced 2024-11-23 20:09:41 +00:00
In response to bug #20362, change the order of operations in vector move assignment so that if the allocator move assignment throws, we aren't left with two objects pointing at the same memory. This is not a complete fix; I am unconvinced that a complete fix is possible. With this change in place, we will leak the old contents of the vector. LWG issue #2106, when adopted, will make this problem illegal. Thanks to Thomas Koeppe for the report and analysis.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@213546 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d5549ccac1
commit
3c2eac62c3
@ -1331,10 +1331,10 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
|
|||||||
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
|
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
|
||||||
{
|
{
|
||||||
deallocate();
|
deallocate();
|
||||||
|
__base::__move_assign_alloc(__c); // this can throw
|
||||||
this->__begin_ = __c.__begin_;
|
this->__begin_ = __c.__begin_;
|
||||||
this->__end_ = __c.__end_;
|
this->__end_ = __c.__end_;
|
||||||
this->__end_cap() = __c.__end_cap();
|
this->__end_cap() = __c.__end_cap();
|
||||||
__base::__move_assign_alloc(__c);
|
|
||||||
__c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
|
__c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
|
||||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||||
__get_db()->swap(this, &__c);
|
__get_db()->swap(this, &__c);
|
||||||
|
Loading…
Reference in New Issue
Block a user