From 1427b3ef7853271bfdf9057c33ab9a03e7fc67b1 Mon Sep 17 00:00:00 2001 From: blagoev Date: Mon, 16 Nov 2020 23:09:02 +0200 Subject: [PATCH] src: create a HandleScope in FinalizeCallback Refs: https://github.com/nodejs/node-addon-api/pull/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: https://github.com/nodejs/node-addon-api/pull/832 Reviewed-By: Gabriel Schulhof Reviewed-By: Kevin Eady Reviewed-By: Michael Dawson Reviewed-By: NickNaso --- napi-inl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/napi-inl.h b/napi-inl.h index 5866fd89c..ab7ece1c8 100644 --- a/napi-inl.h +++ b/napi-inl.h @@ -3977,6 +3977,7 @@ inline napi_value ObjectWrap::StaticSetterCallbackWrapper( template inline void ObjectWrap::FinalizeCallback(napi_env env, void* data, void* /*hint*/) { + HandleScope scope(env); T* instance = static_cast(data); instance->Finalize(Napi::Env(env)); delete instance;