mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +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
1 changed files with 3 additions and 0 deletions
|
@ -29,6 +29,7 @@
|
||||||
#include <AK/Assertions.h>
|
#include <AK/Assertions.h>
|
||||||
#include <AK/Atomic.h>
|
#include <AK/Atomic.h>
|
||||||
#include <AK/Checked.h>
|
#include <AK/Checked.h>
|
||||||
|
#include <AK/Noncopyable.h>
|
||||||
#include <AK/Platform.h>
|
#include <AK/Platform.h>
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
|
|
||||||
|
@ -59,6 +60,8 @@ constexpr auto call_one_ref_left_if_present(...) -> FalseType
|
||||||
}
|
}
|
||||||
|
|
||||||
class RefCountedBase {
|
class RefCountedBase {
|
||||||
|
AK_MAKE_NONCOPYABLE(RefCountedBase)
|
||||||
|
AK_MAKE_NONMOVABLE(RefCountedBase)
|
||||||
public:
|
public:
|
||||||
typedef unsigned int RefCountType;
|
typedef unsigned int RefCountType;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue