1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:57:35 +00:00

AK: Verify that functions aren't modified while they're being invoked

A Function object should not be set to a different functor while the
original functor is currently executing.
This commit is contained in:
Gunnar Beutner 2021-06-04 10:51:13 +02:00 committed by Andreas Kling
parent 44418cb351
commit 8f81d9ad90

View file

@ -205,6 +205,7 @@ private:
template<typename Callable> template<typename Callable>
void init_with_callable(Callable&& callable) void init_with_callable(Callable&& callable)
{ {
VERIFY(m_call_nesting_level == 0);
using WrapperType = CallableWrapper<Callable>; using WrapperType = CallableWrapper<Callable>;
if constexpr (sizeof(WrapperType) > inline_capacity) { if constexpr (sizeof(WrapperType) > inline_capacity) {
*bit_cast<CallableWrapperBase**>(&m_storage) = new WrapperType(move(callable)); *bit_cast<CallableWrapperBase**>(&m_storage) = new WrapperType(move(callable));