Skip to content

Commit

Permalink
fixup! fixup! src: call napi_remove_wrap() in ObjectWrap dtor
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed Jan 14, 2020
1 parent d668812 commit c243f71
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3147,8 +3147,12 @@ inline ObjectWrap<T>::ObjectWrap(const Napi::CallbackInfo& callbackInfo) {

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

0 comments on commit c243f71

Please sign in to comment.