Skip to content

Commit

Permalink
add check IsDestroyedObject
Browse files Browse the repository at this point in the history
  • Loading branch information
0xF6 committed Aug 10, 2024
1 parent 09b6367 commit 548dcdb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions runtime/ishtar.vm/runtime/gc/IshtarGC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,17 @@ public void FreeObject(IshtarObject* obj, CallFrame* frame)
{
using var _ = GCSync.Begin(this);

if (obj->IsDestroyedObject())
{
gcLayout.register_finalizer_no_order(obj, null, frame);
DeleteDebugData((nint)obj);
RefsHeap.Remove((nint)obj);
Stats.total_bytes_requested -= allocatorPool.Return(obj);
Stats.total_allocations--;
Stats.alive_objects--;
return;
}

if (!obj->IsValidObject())
{
VM.FastFail(WNE.STATE_CORRUPT, "trying free memory of invalid object", frame);
Expand Down

0 comments on commit 548dcdb

Please sign in to comment.