diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-06-02 04:57:00 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-06-02 04:57:00 +0000 |
commit | b36940bb348883969466a3514418c5501cdd8140 (patch) | |
tree | 16a52137f375285357c29499b88cf4e161de00cc /include/memory | |
parent | a2cc95e5b7733625e304f9c0eda22e152a1b2b33 (diff) |
Fix leak in __enable_weak_this(). Thanks to Arthur O'Dwyer for finding it.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271487 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/memory')
-rw-r--r-- | include/memory | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/memory b/include/memory index 014635234..8324d1c5f 100644 --- a/include/memory +++ b/include/memory @@ -4122,9 +4122,11 @@ private: { if (__e && __e->__weak_this_.expired()) { - __e->__weak_this_.__ptr_ = const_cast<_Yp*>(static_cast<const _Yp*>(__e)); - __e->__weak_this_.__cntrl_ = __cntrl_; + weak_ptr<_Yp> __tmp; + __tmp.__ptr_ = const_cast<_Yp*>(static_cast<const _Yp*>(__e)); + __tmp.__cntrl_ = __cntrl_; __cntrl_->__add_weak(); + __e->__weak_this_.swap(__tmp); } } |