Skip to content

Commit

Permalink
src: make ObjectWrap dtor virtual
Browse files Browse the repository at this point in the history
Otherwise, subclasses of `ObjectWrap` would not be deleted
correctly by the `delete instance;` line in `FinalizeCallback()`.

(This is also just the right thing to do for classes from which
subclasses are supposed to be created.)
  • Loading branch information
addaleax committed Jan 14, 2020
1 parent 955ff7c commit d668812
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3865,7 +3865,7 @@ inline napi_value ObjectWrap<T>::InstanceSetterCallbackWrapper(

template <typename T>
inline void ObjectWrap<T>::FinalizeCallback(napi_env env, void* data, void* /*hint*/) {
T* instance = reinterpret_cast<T*>(data);
ObjectWrap<T>* instance = static_cast<ObjectWrap<T>*>(data);
instance->Finalize(Napi::Env(env));
delete instance;
}
Expand Down

0 comments on commit d668812

Please sign in to comment.