Skip to content

Commit 0fd142b

Browse files
committed
fixup! fixup! src: call napi_remove_wrap() in ObjectWrap dtor
1 parent f4bfde2 commit 0fd142b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

napi-inl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2815,8 +2815,12 @@ inline ObjectWrap<T>::ObjectWrap(const Napi::CallbackInfo& callbackInfo) {
28152815

28162816
template <typename T>
28172817
inline ObjectWrap<T>::~ObjectWrap() {
2818+
// If the JS object still exists at this point, remove the finalizer added
2819+
// through `napi_wrap()`.
28182820
if (!IsEmpty()) {
28192821
Object object = Value();
2822+
// It is not valid to call `napi_remove_wrap()` with an empty `object`.
2823+
// This happens e.g. during garbage collection.
28202824
if (!object.IsEmpty())
28212825
napi_remove_wrap(Env(), object, nullptr);
28222826
}

0 commit comments

Comments
 (0)