mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 22:37:36 +00:00
AK: Fix ref leak in NonnullRefPtr::operator=(T&).
We would leak a ref when assigning a T& to a NonnullRefPtr that already contains that same T.
This commit is contained in:
parent
d9cc3e453c
commit
6db879ee66
3 changed files with 44 additions and 4 deletions
|
@ -131,10 +131,11 @@ public:
|
|||
|
||||
NonnullRefPtr& operator=(T& object)
|
||||
{
|
||||
if (m_ptr != &object)
|
||||
if (m_ptr != &object) {
|
||||
deref_if_not_null(m_ptr);
|
||||
m_ptr = &object;
|
||||
m_ptr->ref();
|
||||
m_ptr = &object;
|
||||
m_ptr->ref();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue