mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +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
Notes:
sideshowbarker
2024-07-19 05:42:11 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/0ff3c1c34d4 Pull-request: https://github.com/SerenityOS/serenity/pull/2547
1 changed files with 2 additions and 0 deletions
|
@ -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