mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK: Ensure RefCounted types are never copied or moved
Before this, it has been possible to assign a RefCounted object to another RefCounted object. Hilariosly (or sadly), that copied the refcount among the other fields, meaning the target value ended up with a wrong refcount. Ensure this never happens by disallowing copies and moves for RefCounted types.
This commit is contained in:
parent
0ff3c1c34d
commit
3ff651323c
Notes:
sideshowbarker
2024-07-19 05:42:07 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/3ff651323c0 Pull-request: https://github.com/SerenityOS/serenity/pull/2547
1 changed files with 3 additions and 0 deletions
|
@ -29,6 +29,7 @@
|
|||
#include <AK/Assertions.h>
|
||||
#include <AK/Atomic.h>
|
||||
#include <AK/Checked.h>
|
||||
#include <AK/Noncopyable.h>
|
||||
#include <AK/Platform.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
||||
|
@ -59,6 +60,8 @@ constexpr auto call_one_ref_left_if_present(...) -> FalseType
|
|||
}
|
||||
|
||||
class RefCountedBase {
|
||||
AK_MAKE_NONCOPYABLE(RefCountedBase)
|
||||
AK_MAKE_NONMOVABLE(RefCountedBase)
|
||||
public:
|
||||
typedef unsigned int RefCountType;
|
||||
|
||||
|
|
Loading…
Reference in a new issue