summaryrefslogtreecommitdiff
path: root/Tests/AK/TestRefPtr.cpp
AgeCommit message (Collapse)Author
2022-01-11AK+Kernel: Remove one_ref_left() footgunAndreas Kling
This mechanism was unsafe to use in any multithreaded context, since the hook function was invoked on a raw pointer *after* decrementing the local ref count. Since we don't use it for anything anymore, let's just get rid of it.
2021-06-24Everywhere: Use nothrow new with `adopt_{ref,own}_if_nonnull`Daniel Bertalan
This commit converts naked `new`s to `AK::try_make` and `AK::try_create` wherever possible. If the called constructor is private, this can not be done, so we instead now use the standard-defined and compiler-agnostic `new (nothrow)`.
2021-05-14Tests: Fix use-after-free in TestRefPtr.self_observersAndrew Kaster
We can't unref an object to destruction while there's still a live RefPtr to the object, otherwise the RefPtr destructor will try to destroy it again, accessing the refcount of a destroyed object (before realizing that oops! the object is already dead)
2021-05-13AK: Introduce adopt_ref_if_nonnull(..) to aid in Kernel OOM hardeningBrian Gianforcaro
Unfortunately adopt_ref requires a reference, which obviously does not work well with when attempting to harden against allocation failure. The adopt_ref_if_nonnull() variant will allow you to avoid using bare pointers, while still allowing you to handle allocation failure.
2021-05-06Tests: Move AK tests to Tests/AKBrian Gianforcaro