Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
src: fix BaseObject Detach for GC’ed objects
Browse files Browse the repository at this point in the history
This fixes a crash in test/sequential/test-performance-eventloopdelay.js.
This should be squashed into

> src: introduce custom smart pointers for `BaseObject`s

PR-URL: #149
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax authored and jasnell committed Oct 3, 2019
1 parent fb9bc15 commit 9e688dc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/base_object-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ void BaseObject::decrease_refcount() {
if (new_refcount == 0) {
if (metadata->is_detached) {
delete this;
} else if (metadata->wants_weak_jsobj) {
} else if (metadata->wants_weak_jsobj && !persistent_handle_.IsEmpty()) {
MakeWeak();
}
}
}

void BaseObject::increase_refcount() {
unsigned int prev_refcount = pointer_data()->strong_ptr_count++;
if (prev_refcount == 0)
if (prev_refcount == 0 && !persistent_handle_.IsEmpty())
persistent_handle_.ClearWeak();
}

Expand Down

0 comments on commit 9e688dc

Please sign in to comment.