Skip to content

Commit 31b31a3

Browse files
committed
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. PR-URL: #31468 Refs: #31386 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
1 parent 1046816 commit 31b31a3

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/env.cc

Lines changed: 2 additions & 0 deletions
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)