mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
node-api: fix crash in finalization
Refs: https://github.com/nodejs/node-addon-api/issues/906 Refs: https://github.com/nodejs/node/pull/37616 Fix crash introduced by https://github.com/nodejs/node/pull/37616 Signed-off-by: Michael Dawson <mdawson@devrus.com> PR-URL: https://github.com/nodejs/node/pull/37876 Backport-PR-URL: https://github.com/nodejs/node/pull/42512 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
a2f4206415
commit
2aa9ca1ea9
1 file changed
+5
-2
@@ -373,8 +373,11 @@ class Reference : public RefBase {
|
||||
inline void Finalize(bool is_env_teardown = false) override {
|
||||
// During env teardown, `~napi_env()` alone is responsible for finalizing.
|
||||
// Thus, we don't want any stray gc passes to trigger a second call to
|
||||
// `Finalize()`, so let's reset the persistent here.
|
||||
if (is_env_teardown) _persistent.ClearWeak();
|
||||
// `Finalize()`, so let's reset the persistent here if nothing is
|
||||
// keeping it alive.
|
||||
if (is_env_teardown && _persistent.IsWeak()) {
|
||||
_persistent.ClearWeak();
|
||||
}
|
||||
|
||||
// Chain up to perform the rest of the finalization.
|
||||
RefBase::Finalize(is_env_teardown);
|
||||
|
||||
Reference in new issue
Block a user