diff --git a/AK/NonnullRefPtr.h b/AK/NonnullRefPtr.h index c3c3becff9..acc919b2b6 100644 --- a/AK/NonnullRefPtr.h +++ b/AK/NonnullRefPtr.h @@ -74,14 +74,16 @@ public: } RETURN_TYPESTATE(unconsumed) NonnullRefPtr(const NonnullRefPtr& other) - : m_ptr(&const_cast(other).copy_ref().leak_ref()) + : m_ptr(const_cast(other.ptr())) { + m_ptr->ref(); } template RETURN_TYPESTATE(unconsumed) NonnullRefPtr(const NonnullRefPtr& other) - : m_ptr(&const_cast&>(other).copy_ref().leak_ref()) + : m_ptr(const_cast(static_cast((other.ptr())))) { + m_ptr->ref(); } ~NonnullRefPtr() {