LibGC: Clear functions during finalization
A finalized GC::Function should no longer be callable. Clear the underlying AK::Function during finalization so stale references fail as empty callbacks instead of calling through finalized capture storage.
This commit is contained in:
parent
5cf90c0d0d
commit
949889f124
1 changed files with 8 additions and 0 deletions
|
|
@ -18,6 +18,8 @@ class Function final : public Cell {
|
|||
GC_DECLARE_ALLOCATOR(Function);
|
||||
|
||||
public:
|
||||
static constexpr bool OVERRIDES_FINALIZE = true;
|
||||
|
||||
static Ref<Function> create(Heap& heap, ESCAPING AK::Function<T>&& function)
|
||||
{
|
||||
return heap.allocate<Function>(move(function));
|
||||
|
|
@ -25,6 +27,12 @@ public:
|
|||
|
||||
virtual ~Function() override = default;
|
||||
|
||||
virtual void finalize() override
|
||||
{
|
||||
Base::finalize();
|
||||
m_function = nullptr;
|
||||
}
|
||||
|
||||
[[nodiscard]] AK::Function<T> const& function() const { return m_function; }
|
||||
|
||||
private:
|
||||
|
|
|
|||
Loading…
Reference in a new issue