Skip to content

Commit

Permalink
src: create a HandleScope in FinalizeCallback
Browse files Browse the repository at this point in the history
Refs: nodejs/node-addon-api#832

Seems like FinalizeCallback needs to create a HandleScope
since it calls ObjectWrap::~ObjectWrap() which might need
to create a temporary Object handle here
https://github.com/nodejs/node-addon-api/blob/master/napi-inl.h#L3558

at Realm (https://github.com/realm/realm-js) we have crashes
with stacktrace at this location.

While fixed in core for later versions we still need for
older versions of Node.js

PR-URL: nodejs/node-addon-api#832
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Kevin Eady <kevin.c.eady@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: NickNaso <nicoladelgobbo@gmail.com>
  • Loading branch information
John French committed Nov 20, 2020
1 parent 5ff1acc commit f508c02
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3977,6 +3977,7 @@ inline napi_value ObjectWrap<T>::StaticSetterCallbackWrapper(

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

0 comments on commit f508c02

Please sign in to comment.