Skip to content

Commit 56a4509

Browse files
addaleaxMylesBorins
authored andcommitted
src: harden running native SetImmediate()s slightly
Prevent mistakes like the one fixed by the previous commit by destroying the callback immediately after it has been called. Backport-PR-URL: #32301 PR-URL: #31468 Refs: #31386 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
1 parent c5de212 commit 56a4509

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: src/env.cc

+2
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,8 @@ void Environment::RunAndClearNativeImmediates(bool only_refed) {
698698
if (head->is_refed() || !only_refed)
699699
head->Call(this);
700700

701+
head.reset(); // Destroy now so that this is also observed by try_catch.
702+
701703
if (UNLIKELY(try_catch.HasCaught())) {
702704
if (!try_catch.HasTerminated() && can_call_into_js())
703705
errors::TriggerUncaughtException(isolate(), try_catch);

0 commit comments

Comments
 (0)