Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2aa9ca1

Browse filesBrowse files
mhdawsonrichardlau
authored andcommitted
node-api: fix crash in finalization
Refs: nodejs/node-addon-api#906 Refs: #37616 Fix crash introduced by #37616 Signed-off-by: Michael Dawson <mdawson@devrus.com> PR-URL: #37876 Backport-PR-URL: #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>
1 parent a2f4206 commit 2aa9ca1
Copy full SHA for 2aa9ca1

1 file changed

+5-2Lines changed: 5 additions & 2 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/js_native_api_v8.cc‎

Copy file name to clipboardExpand all lines: src/js_native_api_v8.cc
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,11 @@ class Reference : public RefBase {
373373
inline void Finalize(bool is_env_teardown = false) override {
374374
// During env teardown, `~napi_env()` alone is responsible for finalizing.
375375
// Thus, we don't want any stray gc passes to trigger a second call to
376-
// `Finalize()`, so let's reset the persistent here.
377-
if (is_env_teardown) _persistent.ClearWeak();
376+
// `Finalize()`, so let's reset the persistent here if nothing is
377+
// keeping it alive.
378+
if (is_env_teardown && _persistent.IsWeak()) {
379+
_persistent.ClearWeak();
380+
}
378381

379382
// Chain up to perform the rest of the finalization.
380383
RefBase::Finalize(is_env_teardown);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.