AK: Avoid clearing pointer wrappers during destruction
Delete or unref directly from RefPtr, NonnullRefPtr, and NonnullOwnPtr destructors instead of calling clear() or exchanging the member pointer. This avoids storing null when the wrapper lifetime is ending.
This commit is contained in:
parent
ccc578e0c0
commit
2a0bc6a6e0
3 changed files with 3 additions and 4 deletions
|
|
@ -47,7 +47,7 @@ public:
|
|||
}
|
||||
~NonnullOwnPtr()
|
||||
{
|
||||
clear();
|
||||
delete m_ptr;
|
||||
#ifdef SANITIZE_PTRS
|
||||
m_ptr = (T*)(explode_byte(NONNULLOWNPTR_SCRUB_BYTE));
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -93,8 +93,7 @@ public:
|
|||
|
||||
ALWAYS_INLINE ~NonnullRefPtr()
|
||||
{
|
||||
auto* ptr = exchange(m_ptr, nullptr);
|
||||
unref_if_not_null(ptr);
|
||||
unref_if_not_null(m_ptr);
|
||||
#ifdef SANITIZE_PTRS
|
||||
m_ptr = reinterpret_cast<T*>(explode_byte(NONNULLREFPTR_SCRUB_BYTE));
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public:
|
|||
|
||||
ALWAYS_INLINE ~RefPtr()
|
||||
{
|
||||
clear();
|
||||
unref_if_not_null(m_ptr);
|
||||
#ifdef SANITIZE_PTRS
|
||||
m_ptr = reinterpret_cast<T*>(explode_byte(REFPTR_SCRUB_BYTE));
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue