Skip to content

Commit 1427b3e

Browse files
blagoevmhdawson
authored andcommitted
src: create a HandleScope in FinalizeCallback
Refs: #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: #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>
1 parent 8fb5820 commit 1427b3e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

napi-inl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3977,6 +3977,7 @@ inline napi_value ObjectWrap<T>::StaticSetterCallbackWrapper(
39773977

39783978
template <typename T>
39793979
inline void ObjectWrap<T>::FinalizeCallback(napi_env env, void* data, void* /*hint*/) {
3980+
HandleScope scope(env);
39803981
T* instance = static_cast<T*>(data);
39813982
instance->Finalize(Napi::Env(env));
39823983
delete instance;

0 commit comments

Comments
 (0)