mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 11:20:03 +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:
committed by
Andreas Kling
parent
c80e657dda
commit
0ff3c1c34d
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include <AK/Assertions.h>
|
#include <AK/Assertions.h>
|
||||||
#include <AK/Atomic.h>
|
#include <AK/Atomic.h>
|
||||||
|
#include <AK/Checked.h>
|
||||||
#include <AK/Platform.h>
|
#include <AK/Platform.h>
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
|
|
||||||
@@ -65,6 +66,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto old_ref_count = m_ref_count++;
|
auto old_ref_count = m_ref_count++;
|
||||||
ASSERT(old_ref_count > 0);
|
ASSERT(old_ref_count > 0);
|
||||||
|
ASSERT(!Checked<RefCountType>::addition_would_overflow(old_ref_count, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE RefCountType ref_count() const
|
ALWAYS_INLINE RefCountType ref_count() const
|
||||||
|
|||||||
Reference in New Issue
Block a user