mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-07 00:19:27 +00:00
AK: Assert refcount doesn't overflow
We don't really have a good way to prevent this kind of overflow, but let's at least immediately panic in this case.
This commit is contained in:
parent
c80e657dda
commit
0ff3c1c34d
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/Atomic.h>
|
||||
#include <AK/Checked.h>
|
||||
#include <AK/Platform.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
||||
|
@ -65,6 +66,7 @@ public:
|
|||
{
|
||||
auto old_ref_count = m_ref_count++;
|
||||
ASSERT(old_ref_count > 0);
|
||||
ASSERT(!Checked<RefCountType>::addition_would_overflow(old_ref_count, 1));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE RefCountType ref_count() const
|
||||
|
|
Loading…
Reference in a new issue