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

Commit 142ee34

Browse files
addaleaxjasnell
authored andcommitted
src: fix BaseObject Detach for GC’ed objects
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>
1 parent ef35cba commit 142ee34

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/base_object-inl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,15 @@ void BaseObject::decrease_refcount() {
187187
if (new_refcount == 0) {
188188
if (metadata->is_detached) {
189189
delete this;
190-
} else if (metadata->wants_weak_jsobj) {
190+
} else if (metadata->wants_weak_jsobj && !persistent_handle_.IsEmpty()) {
191191
MakeWeak();
192192
}
193193
}
194194
}
195195

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

0 commit comments

Comments
 (0)